diff --git a/product_cores/__manifest__.py b/product_cores/__manifest__.py index 08b04f83..d245ddf1 100755 --- a/product_cores/__manifest__.py +++ b/product_cores/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Product Cores', 'author': 'Hibou Corp. ', - 'version': '13.0.1.0.1', + 'version': '14.0.1.0.0', 'category': 'Tools', 'license': 'OPL-1', 'summary': 'Charge customers core deposits.', diff --git a/product_cores/models/account.py b/product_cores/models/account.py index c2bc3d61..7ebf1401 100644 --- a/product_cores/models/account.py +++ b/product_cores/models/account.py @@ -7,32 +7,32 @@ from odoo import models class AccountMove(models.Model): _inherit = 'account.move' - def post(self): + def _post(self, soft=True): if self._context.get('move_reverse_cancel'): - return super(AccountMove, self).post() + return super(AccountMove, self)._post(soft) self._product_core_set_date_maturity() - return super(AccountMove, self).post() + return super(AccountMove, self)._post(soft) def _product_core_set_date_maturity(self): for move in self: for line in move.invoice_line_ids.filtered(lambda l: l.product_id.core_ok and l.product_id.type == 'service'): regular_date_maturity = line.date + timedelta(days=(line.product_id.product_core_validity or 0)) - if move.type in ('in_invoice', 'in_refund', 'in_receipt'): + if move.move_type in ('in_invoice', 'in_refund', 'in_receipt'): # derive from purchase - if move.type == 'in_refund' and line.purchase_line_id: + if move.move_type == 'in_refund' and line.purchase_line_id: # try to date from original po_move_lines = self.search([('purchase_line_id', '=', line.purchase_line_id.id)]) - po_move_lines = po_move_lines.filtered(lambda l: l.move_id.type == 'in_invoice') + po_move_lines = po_move_lines.filtered(lambda l: l.move_id.move_type == 'in_invoice') if po_move_lines: line.date_maturity = po_move_lines[0].date_maturity or regular_date_maturity else: line.date_maturity = regular_date_maturity else: line.date_maturity = regular_date_maturity - elif move.type in ('out_invoice', 'out_refund', 'out_receipt'): + elif move.move_type in ('out_invoice', 'out_refund', 'out_receipt'): # derive from sale - if move.type == 'out_refund' and line.sale_line_ids: - other_move_lines = line.sale_line_ids.mapped('invoice_lines').filtered(lambda l: l.move_id.type == 'out_invoice') + if move.move_type == 'out_refund' and line.sale_line_ids: + other_move_lines = line.sale_line_ids.mapped('invoice_lines').filtered(lambda l: l.move_id.move_type == 'out_invoice') if other_move_lines: line.date_maturity = other_move_lines[0].date_maturity or regular_date_maturity else: diff --git a/product_cores/tests/test_product_cores.py b/product_cores/tests/test_product_cores.py index b2f2181e..e7a760e8 100644 --- a/product_cores/tests/test_product_cores.py +++ b/product_cores/tests/test_product_cores.py @@ -125,7 +125,7 @@ class TestProductCores(common.TransactionCase): f.purchase_id = purchase vendor_bill = f.save() self.assertEqual(len(vendor_bill.invoice_line_ids), 2) - vendor_bill.post() + vendor_bill.action_post() for line in vendor_bill.invoice_line_ids: pol = purchase.order_line.filtered(lambda l: l.product_id == line.product_id) self.assertTrue(pol) @@ -209,9 +209,10 @@ class TestProductCores(common.TransactionCase): sale.picking_ids.action_assign() self.assertEqual(so_line.product_uom_qty, sale.picking_ids.move_lines.reserved_availability) - res_dict = sale.picking_ids.button_validate() - wizard = self.env[(res_dict.get('res_model'))].browse(res_dict.get('res_id')) - wizard.process() + for move_line in sale.picking_ids.mapped('move_lines.move_line_ids'): + move_line.qty_done = move_line.product_uom_qty + sale.picking_ids.button_validate() + self.assertEqual(sale.picking_ids.state, 'done') self.assertEqual(so_line.qty_delivered, so_line.product_uom_qty) # Ensure all products are delivered. @@ -243,8 +244,8 @@ class TestProductCores(common.TransactionCase): return_picking = sale.picking_ids.filtered(lambda p: p.state != 'done') self.assertTrue(return_picking) - res_dict = return_picking.button_validate() - wizard = self.env[(res_dict.get('res_model'))].browse(res_dict.get('res_id')) - wizard.process() + for move_line in return_picking.mapped('move_lines.move_line_ids'): + move_line.qty_done = move_line.product_uom_qty + return_picking.button_validate() self.assertTrue(all(l.qty_delivered == 0.0 for l in sale.order_line))