55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
# 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
|
|
})
|