[wip] funcinando la creación automática de ubicaciones cuando se activa el acepta depósitos en la ficha del partner.
Crea dos ubicaciones padres para meter todos los depósitos en ellas.
This commit is contained in:
parent
16a72610f2
commit
3523629d60
7 changed files with 99 additions and 3 deletions
|
@ -1 +1,2 @@
|
|||
from . import stock_picking
|
||||
from . import res_partner
|
||||
|
|
55
stock_picking_deposito/models/res_partner.py
Normal file
55
stock_picking_deposito/models/res_partner.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
# Copyright (C) 2021: Criptomart (<https://criptomart.net/>)
|
||||
# @author: Criptomart (<tech@criptomart.net>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
#import logging
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
#_logger = logging.getLogger(__name__)
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
deposit_sale_accept = fields.Boolean(
|
||||
string='Acepta depósitos de venta',
|
||||
help='Éste cliente acepta nuestro material a depósito',
|
||||
)
|
||||
deposit_buy_accept = fields.Boolean(
|
||||
string='Acepta depósitos de compra',
|
||||
help='Éste proveedor nos deja material a depósito',
|
||||
)
|
||||
deposit_sale_location_id = fields.Many2one(
|
||||
comodel_name='stock.location',
|
||||
string='Ubicación de depósito de ventas',
|
||||
help="La ubicación que se usará para gestionar el depósito que dejamos a éste proveedor"
|
||||
)
|
||||
deposit_buy_location_id = fields.Many2one(
|
||||
comodel_name='stock.location',
|
||||
string='Ubicación de depósito de compras',
|
||||
help="La ubicación que se usará para gestionar el material que éste proveedor nos deja en depósito."
|
||||
)
|
||||
|
||||
@api.onchange('deposit_sale_accept')
|
||||
def _onchange_deposit_sale_accept(self):
|
||||
if self.deposit_sale_accept and not self.deposit_sale_location_id:
|
||||
new_loc = self.env['stock.location'].create({
|
||||
'usage': 'internal',
|
||||
'name': self.name,
|
||||
'location_id': self.env.ref('stock_picking_deposito.location_deposit_sale').id
|
||||
})
|
||||
self.update({
|
||||
'deposit_sale_location_id': new_loc
|
||||
})
|
||||
|
||||
@api.onchange('deposit_buy_accept')
|
||||
def _onchange_deposit_buy_accept(self):
|
||||
if self.deposit_buy_accept and not self.deposit_buy_location_id:
|
||||
new_loc = self.env['stock.location'].create({
|
||||
'usage': 'internal',
|
||||
'name': self.name,
|
||||
'location_id': self.env.ref('stock_picking_deposito.location_deposit_buy').id
|
||||
})
|
||||
self.update({
|
||||
'deposit_buy_location_id': new_loc
|
||||
})
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2021 Criptomart SLL
|
||||
# Copyright 2021 Criptomart
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
|
||||
from odoo import api, models, fields
|
||||
|
@ -18,4 +18,3 @@ class StockPicking(models.Model):
|
|||
string='Es un Depósito',
|
||||
help='Éste albarán es un depósito, no una compra final',
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue