[wip] Botón en el partner para realizar la liquidación
Funcionando hasta tener una lista de productos t las cantidades, hay que crear una factura de compra con ella.
This commit is contained in:
parent
53ad5dffb3
commit
fbda713b52
2 changed files with 71 additions and 2 deletions
|
@ -2,11 +2,13 @@
|
||||||
# @author: Criptomart (<tech@criptomart.net>)
|
# @author: Criptomart (<tech@criptomart.net>)
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
#import logging
|
import logging
|
||||||
|
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
|
|
||||||
#_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
|
@ -29,6 +31,10 @@ class ResPartner(models.Model):
|
||||||
string='Ubicación de depósito de compras',
|
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."
|
help="La ubicación que se usará para gestionar el material que éste proveedor nos deja en depósito."
|
||||||
)
|
)
|
||||||
|
deposit_buy_last_liquidation_date = fields.Date(
|
||||||
|
string='Fecha de la última liquidación de compras',
|
||||||
|
help="Cuándo se realizó la última liquidación de compras con éste proveedor."
|
||||||
|
)
|
||||||
|
|
||||||
@api.onchange('deposit_sale_accept')
|
@api.onchange('deposit_sale_accept')
|
||||||
def _onchange_deposit_sale_accept(self):
|
def _onchange_deposit_sale_accept(self):
|
||||||
|
@ -53,3 +59,19 @@ class ResPartner(models.Model):
|
||||||
self.update({
|
self.update({
|
||||||
'deposit_buy_location_id': new_loc
|
'deposit_buy_location_id': new_loc
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def make_liquidation_buy(self):
|
||||||
|
_logger.warning("make_liquidation : %s" %self)
|
||||||
|
search_vals = [
|
||||||
|
('location_id', '=', self.deposit_buy_location_id.id),
|
||||||
|
('location_dest_id', '=', self.env.ref('stock.stock_location_customers').id),
|
||||||
|
]
|
||||||
|
if self.deposit_buy_last_liquidation_date:
|
||||||
|
search_vals += ('date', '>', self.deposit_buy_last_liquidation_date)
|
||||||
|
_logger.warning("search_vals : %s" %search_vals)
|
||||||
|
move_lines = self.env['stock.move.line'].search(search_vals)
|
||||||
|
product_list = Counter()
|
||||||
|
for mv in move_lines:
|
||||||
|
product_list += {'id': mv.product_id.id, 'qty': mv.qty_done}
|
||||||
|
_logger.warning("product_list : %s" %product_list)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
|
<record model="ir.actions.server" id="action_res_partner_liquidacion_buy">
|
||||||
|
<field name="name">Liquidación Depósito Compras</field>
|
||||||
|
<field name="condition">True</field>
|
||||||
|
<field name="type">ir.actions.server</field>
|
||||||
|
<field name="model_id" ref="base.model_res_partner" />
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">record.make_liquidation_buy()</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="view_partner_form" model="ir.ui.view">
|
<record id="view_partner_form" model="ir.ui.view">
|
||||||
<field name="model">res.partner</field>
|
<field name="model">res.partner</field>
|
||||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
<field name="priority">200</field>
|
<field name="priority">200</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
|
||||||
<field name="vat" position="after">
|
<field name="vat" position="after">
|
||||||
<group>
|
<group>
|
||||||
<field name="deposit_sale_accept"/>
|
<field name="deposit_sale_accept"/>
|
||||||
|
@ -14,8 +24,45 @@
|
||||||
<field name="deposit_buy_location_id" />
|
<field name="deposit_buy_location_id" />
|
||||||
</group>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
|
<div name="button_box" position="inside">
|
||||||
|
<button name="%(stock_picking_deposito.action_res_partner_liquidacion_buy)d"
|
||||||
|
string="Liquida Compras"
|
||||||
|
type="action"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-calendar"
|
||||||
|
help="Realiza el informe de liquidación para éste proveedor."
|
||||||
|
groups="stock.group_stock_manager"
|
||||||
|
attrs="{'invisible': [('deposit_buy_accept', '!=', True)]}"
|
||||||
|
>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
<!--
|
||||||
|
<record model="ir.actions.act_window" id="action_res_partner_liquidacion_buy">
|
||||||
|
<field name="name">Informe de liquidación</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">stock.picking</field>
|
||||||
|
<field name="view_type">tree</field>
|
||||||
|
<field name="view_mode">tree</field>
|
||||||
|
<field name="context">{'default_location_dest_id': stock.stock_location_customers, 'default_partner_id': active_id}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_res_partner_liquidacion_tree" model="ir.ui.view">
|
||||||
|
<field name="name">res.partner.liquidacion.list</field>
|
||||||
|
<field name="model">stock.picking</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree create='false' edit='false' delete='false'>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="partner_id"/>
|
||||||
|
<field name="category_id"/>
|
||||||
|
<field name="owned_share" sum="Total Owned Shares"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
-->
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Add table
Reference in a new issue