diff --git a/reception_purchase_total/__init__.py b/reception_purchase_total/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/reception_purchase_total/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/reception_purchase_total/__manifest__.py b/reception_purchase_total/__manifest__.py new file mode 100644 index 0000000..dee7ca0 --- /dev/null +++ b/reception_purchase_total/__manifest__.py @@ -0,0 +1,33 @@ +{ + "name": "Reception Purchase Total", + "version": "18.0.1.0.0", + "category": "Inventory/Purchase", + "summary": "Display purchase totals on stock reception views", + "description": """ +This module adds purchase price totals to stock reception views. Specifically: + +* Adds a total amount column to stock move lines in receptions, showing the purchase price * quantity +* Shows a total amount at the bottom of operations and detailed operations tabs in: + - Reception form view + - Batch Transfer form view +* Links stock moves to their original purchase order line prices + +Technical Details: +* Extends stock.move to compute total amount based on purchase line price +* Adds computed fields and view inheritance to display totals +* Compatible with standard Odoo purchase and inventory workflows + """, + "author": "Bemade Inc.", + "website": "https://www.bemade.org", + "depends": [ + "stock", + "purchase_stock", + ], + "data": [ + "views/stock_picking_views.xml", + ], + "license": "LGPL-3", + "installable": True, + "auto_install": False, + "application": False, +} diff --git a/reception_purchase_total/models/__init__.py b/reception_purchase_total/models/__init__.py new file mode 100644 index 0000000..f800274 --- /dev/null +++ b/reception_purchase_total/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_move +from . import stock_move_line diff --git a/reception_purchase_total/models/stock_move.py b/reception_purchase_total/models/stock_move.py new file mode 100644 index 0000000..8ad57a4 --- /dev/null +++ b/reception_purchase_total/models/stock_move.py @@ -0,0 +1,32 @@ +from odoo import api, fields, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + purchase_price_unit = fields.Float( + string="Purchase Unit Price", + related="purchase_line_id.price_unit", + digits="Product Price", + readonly=True, + help="Unit price from the related purchase order line", + ) + purchase_price_total = fields.Float( + string="Purchase Total", + compute="_compute_purchase_price_total", + help="Total price based on purchase unit price and move quantity", + ) + picking_type_code = fields.Selection( + related="picking_id.picking_type_code", + readonly=True, + ) + purchase_currency_id = fields.Many2one( + related="purchase_line_id.currency_id", + string="Purchase Currency", + readonly=True, + ) + + @api.depends("purchase_price_unit", "quantity") + def _compute_purchase_price_total(self): + for move in self: + move.purchase_price_total = move.purchase_price_unit * move.quantity diff --git a/reception_purchase_total/models/stock_move_line.py b/reception_purchase_total/models/stock_move_line.py new file mode 100644 index 0000000..24669ac --- /dev/null +++ b/reception_purchase_total/models/stock_move_line.py @@ -0,0 +1,34 @@ +from odoo import fields, models, api + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + picking_type_code = fields.Selection( + related="picking_id.picking_type_id.code", + string="Operation Type", + store=True, + readonly=True, + ) + + purchase_price_unit = fields.Float( + string="Purchase Unit Price", + related="move_id.purchase_price_unit", + readonly=True, + help="Unit price from the related purchase order line", + ) + purchase_price_total = fields.Float( + string="Purchase Total", + compute="_compute_purchase_price_total", + help="Total price for this move line based on purchase price and quantity", + ) + purchase_currency_id = fields.Many2one( + related="move_id.purchase_currency_id", + string="Purchase Currency", + readonly=True, + ) + + @api.depends("purchase_price_unit", "quantity") + def _compute_purchase_price_total(self): + for line in self: + line.purchase_price_total = line.purchase_price_unit * line.quantity diff --git a/reception_purchase_total/views/stock_picking_views.xml b/reception_purchase_total/views/stock_picking_views.xml new file mode 100644 index 0000000..2ca1f28 --- /dev/null +++ b/reception_purchase_total/views/stock_picking_views.xml @@ -0,0 +1,48 @@ + + + + + stock.move.tree.inherit.reception.purchase.total + stock.move + + + + + + + + + + + + + + stock.move.line.tree.inherit.reception.purchase.total + stock.move.line + + + + + + + + + + + + + + stock.picking.form.inherit.reception.purchase.total + stock.picking + + + + + + + + + + + +