From fbda713b52266c6ac17d1513da03912ee610db18 Mon Sep 17 00:00:00 2001 From: santiky Date: Thu, 9 Sep 2021 20:10:10 +0200 Subject: [PATCH] =?UTF-8?q?[wip]=20Bot=C3=B3n=20en=20el=20partner=20para?= =?UTF-8?q?=20realizar=20la=20liquidaci=C3=B3n=20Funcionando=20hasta=20ten?= =?UTF-8?q?er=20una=20lista=20de=20productos=20t=20las=20cantidades,=20hay?= =?UTF-8?q?=20que=20crear=20una=20factura=20de=20compra=20con=20ella.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stock_picking_deposito/models/res_partner.py | 26 +++++++++- .../views/view_res_partner.xml | 47 +++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/stock_picking_deposito/models/res_partner.py b/stock_picking_deposito/models/res_partner.py index 7bc8152..bc3bfc7 100644 --- a/stock_picking_deposito/models/res_partner.py +++ b/stock_picking_deposito/models/res_partner.py @@ -2,11 +2,13 @@ # @author: Criptomart () # 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 -#_logger = logging.getLogger(__name__) +_logger = logging.getLogger(__name__) class ResPartner(models.Model): _inherit = 'res.partner' @@ -29,6 +31,10 @@ class ResPartner(models.Model): 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." ) + 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') def _onchange_deposit_sale_accept(self): @@ -53,3 +59,19 @@ class ResPartner(models.Model): self.update({ '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) + diff --git a/stock_picking_deposito/views/view_res_partner.xml b/stock_picking_deposito/views/view_res_partner.xml index 496ca45..ee03284 100644 --- a/stock_picking_deposito/views/view_res_partner.xml +++ b/stock_picking_deposito/views/view_res_partner.xml @@ -1,11 +1,21 @@ + + Liquidación Depósito Compras + True + ir.actions.server + + code + record.make_liquidation_buy() + + res.partner 200 + @@ -14,8 +24,45 @@ + +
+ +
+
+