upgrade depositos a v16. Añadida configuración para definir la lista de

precios que se aplica en los depósitos de venta.
This commit is contained in:
snt 2024-09-10 16:53:28 +02:00
parent bee00e0867
commit ca3ff032a2
6 changed files with 34 additions and 43 deletions

View file

@ -1,13 +1,9 @@
# Copyright (C) 2021: Criptomart (<https://criptomart.net/>)
# @author: Criptomart (<tech@criptomart.net>)
# Copyright (C) 2021-2024: Criptomart (<https://criptomart.net/>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
#import logging
from odoo import models, fields, api
from odoo.exceptions import ValidationError, Warning
#_logger = logging.getLogger(__name__)
class ResPartner(models.Model):
_inherit = 'res.partner'
@ -85,33 +81,32 @@ class ResPartner(models.Model):
new_prod = True
for p in product_list:
if p[2]['product_id'] == mv.product_id.id:
p[2]['quantity'] += mv.qty_done
p[2]['debit'] += mv.qty_done * mv.product_id.standard_price
new_prod = False
break
if new_prod:
product_list.append([0, False, {
'product_id': mv.product_id.id,
'quantity': mv.qty_done,
'debit': mv.qty_done * mv.product_id.standard_price,
'name': mv.product_id.name,
'price_unit': mv.product_id.lst_price,
'uom_id': mv.product_id.uom_id.id,
'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id
'tax_ids' : mv.product_id.supplier_taxes_id,
}
])
if len(product_list):
self.deposit_buy_last_liquidation_date = fields.datetime.now()
invoice_vals = invoice_obj.default_get(invoice_obj._fields.keys())
inv_lines = []
invoice_vals.update({
'origin': "Liquidación Compras " + self.deposit_buy_last_liquidation_date.strftime("%d-%m-%Y"),
'type': 'in_invoice',
'date_invoice': self.deposit_buy_last_liquidation_date.strftime("%Y-%m-%d %H:%M:%S"),
'ref': "Liquidación Compras " + self.deposit_buy_last_liquidation_date.strftime("%d-%m-%Y"),
'financial_type': 'payable',
'journal_id': self.env.user.company_id.deposit_journal_id.id,
'partner_id': self.id,
'invoice_line_ids': product_list,
'company_id': self.company_id.id,
})
invoice = invoice_obj.create(invoice_vals)
views = [(self.env.ref('account.invoice_form').id, 'form')]
self.deposit_buy_last_liquidation_date = fields.datetime.now()
views = [(self.env.ref('account.view_move_form').id, 'form')]
return {
'type': 'ir.actions.act_window',
'res_model': 'account.move',
@ -139,8 +134,6 @@ class ResPartner(models.Model):
'product_id': mv.product_id.id,
'product_uom_qty': mv.quantity,
'name': mv.product_id.name,
'price_unit': mv.product_id.lst_price,
'product_uom': mv.product_id.uom_id.id,
}
])
if len(product_list):
@ -150,9 +143,10 @@ class ResPartner(models.Model):
'partner_id': self.id,
'origin': "Liquidación Ventas " + self.deposit_sale_last_liquidation_date.strftime("%d-%m-%Y"),
'date_order': self.deposit_sale_last_liquidation_date.strftime("%Y-%m-%d %H:%M:%S"),
#'journal_id': self.env.user.company_id.deposit_journal_id.id,
'order_line': product_list,
'warehouse_id': self.env.ref('stock_picking_deposito.wh_deposits').id
'warehouse_id': self.env.ref('stock_picking_deposito.wh_deposits').id,
'pricelist_id': self.env.user.company_id.retail_pricelist.id,
})
sale_order = self.env['sale.order'].sudo().create(so_vals)
views = [(self.env.ref('sale.view_order_form').id, 'form')]
@ -170,4 +164,3 @@ class ResPartner(models.Model):
else:
msg += "Todavía no se ha realizado ninguna liquidación de ventas a éste proveedor."
raise ValidationError(msg)