upgrade depositos a v16. Añadida configuración para definir la lista de
precios que se aplica en los depósitos de venta.
This commit is contained in:
parent
bee00e0867
commit
ca3ff032a2
6 changed files with 34 additions and 43 deletions
|
|
@ -1,12 +1,12 @@
|
|||
# Copyright 2021 Criptomart
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
|
||||
#import logging
|
||||
import logging
|
||||
|
||||
from odoo import api, models, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
#_logger = logging.getLogger(__name__)
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class PickingType(models.Model):
|
||||
_inherit = 'stock.picking.type'
|
||||
|
|
@ -14,7 +14,7 @@ class PickingType(models.Model):
|
|||
is_deposit = fields.Boolean(
|
||||
string='Depósito',
|
||||
help='Éste albarán es un depósito, no es una venta final.',
|
||||
default= False,
|
||||
default= False,
|
||||
)
|
||||
|
||||
class Picking(models.Model):
|
||||
|
|
@ -22,20 +22,10 @@ class Picking(models.Model):
|
|||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get("partner_id") and vals.get("location_id") == self.env.ref("stock_picking_deposito.stock_location_deposits_stock").id:
|
||||
partner = self.env['res.partner'].browse(vals.get("partner_id"))
|
||||
vals['location_id'] = partner.deposit_sale_location_id.id
|
||||
return super().create(vals)
|
||||
|
||||
@api.onchange('picking_type_id','partner_id')
|
||||
def onchange_picking_type(self):
|
||||
super(Picking, self).onchange_picking_type()
|
||||
if self.picking_type_id.is_deposit and self.partner_id:
|
||||
self.change_dest_location()
|
||||
if self.partner_id and self.location_id == self.env.ref("stock_picking_deposito.stock_location_deposits_stock"):
|
||||
self.update({
|
||||
'location_id': self.partner_id.deposit_sale_location_id.id,
|
||||
})
|
||||
pick = super().create(vals)
|
||||
if pick.picking_type_id.is_deposit:
|
||||
pick.change_dest_location()
|
||||
return pick
|
||||
|
||||
def change_dest_location(self):
|
||||
if self.picking_type_id.code == 'internal':
|
||||
|
|
@ -52,4 +42,3 @@ class Picking(models.Model):
|
|||
self.update({
|
||||
'location_dest_id': self.partner_id.deposit_buy_location_id.id,
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue