[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,4 +1,4 @@
|
|||
# Copyright 2021 Criptomart
|
||||
# Copyright 2021 Criptomart
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
{
|
||||
"name": "Stock Picking Depósito",
|
||||
|
@ -16,5 +16,7 @@
|
|||
],
|
||||
"data": [
|
||||
"views/stock_picking.xml",
|
||||
"views/view_res_partner.xml",
|
||||
"data/data.xml",
|
||||
],
|
||||
}
|
||||
|
|
17
stock_picking_deposito/data/data.xml
Normal file
17
stock_picking_deposito/data/data.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<odoo>
|
||||
<data noupdate="0">
|
||||
|
||||
<record id="location_deposit_buy" model="stock.location">
|
||||
<field name="name">Depósitos Entradas</field>
|
||||
<field name="usage">internal</field>
|
||||
<field name="location_id" ref="stock.stock_location_stock"/>
|
||||
</record>
|
||||
|
||||
<record id="location_deposit_sale" model="stock.location">
|
||||
<field name="name">Depósitos Salidas</field>
|
||||
<field name="usage">internal</field>
|
||||
<field name="location_id" ref="stock.stock_location_locations"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
|
@ -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',
|
||||
)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- <record id="view_picking_type_form_inherit" model="ir.ui.view">
|
||||
<field name="name">Operation Types inherit</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_type_form" />
|
||||
|
|
21
stock_picking_deposito/views/view_res_partner.xml
Normal file
21
stock_picking_deposito/views/view_res_partner.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="view_partner_form" model="ir.ui.view">
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="priority">200</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="vat" position="after">
|
||||
<group>
|
||||
<field name="deposit_sale_accept"/>
|
||||
<field name="deposit_sale_location_id" />
|
||||
<field name="deposit_buy_accept"/>
|
||||
<field name="deposit_buy_location_id" />
|
||||
</group>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
Loading…
Add table
Reference in a new issue