diff --git a/README.md b/README.md index f2bc3370eb..fed23a56a2 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ addon | version | maintainers | summary [pos_membership](pos_membership/) | 16.0.1.0.0 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Implement features of membership module in the Point of sale UI. [pos_order_remove_line](pos_order_remove_line/) | 16.0.1.1.0 | [![robyf70](https://github.com/robyf70.png?size=30px)](https://github.com/robyf70) | Add button to remove POS order line. [pos_order_reorder](pos_order_reorder/) | 16.0.0.1.0 | [![GabbasovDinar](https://github.com/GabbasovDinar.png?size=30px)](https://github.com/GabbasovDinar) [![CetmixGitDrone](https://github.com/CetmixGitDrone.png?size=30px)](https://github.com/CetmixGitDrone) | Simple Re-order in the Point of Sale -[pos_order_to_sale_order](pos_order_to_sale_order/) | 16.0.1.0.4 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | PoS Order To Sale Order +[pos_order_to_sale_order](pos_order_to_sale_order/) | 16.0.1.0.5 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | PoS Order To Sale Order [pos_partner_birthdate](pos_partner_birthdate/) | 16.0.1.0.1 | [![ecino](https://github.com/ecino.png?size=30px)](https://github.com/ecino) | Adds the birthdate in the customer screen of POS [pos_payment_change](pos_payment_change/) | 16.0.1.0.0 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Allow cashier to change order payments, as long as the session is not closed. [pos_payment_terminal](pos_payment_terminal/) | 16.0.1.0.1 | | Point of sale: support generic payment terminal diff --git a/pos_order_to_sale_order/__manifest__.py b/pos_order_to_sale_order/__manifest__.py index ea01aa07c0..71a9c183bb 100644 --- a/pos_order_to_sale_order/__manifest__.py +++ b/pos_order_to_sale_order/__manifest__.py @@ -4,7 +4,7 @@ { "name": "PoS Order To Sale Order", - "version": "16.0.1.0.4", + "version": "16.0.1.0.5", "author": "GRAP,Odoo Community Association (OCA)", "category": "Point Of Sale", "license": "AGPL-3", diff --git a/pos_order_to_sale_order/models/sale_order.py b/pos_order_to_sale_order/models/sale_order.py index 91295a425d..be32ace84d 100644 --- a/pos_order_to_sale_order/models/sale_order.py +++ b/pos_order_to_sale_order/models/sale_order.py @@ -2,7 +2,7 @@ # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import _, api, models +from odoo import Command, _, api, models class SaleOrder(models.Model): @@ -12,6 +12,11 @@ class SaleOrder(models.Model): def _prepare_from_pos(self, order_data): PosSession = self.env["pos.session"] session = PosSession.browse(order_data["pos_session_id"]) + SaleOrderLine = self.env["sale.order.line"] + order_lines = [ + Command.create(SaleOrderLine._prepare_from_pos(line[2])) + for line in order_data["lines"] + ] return { "partner_id": order_data["partner_id"], "origin": _("Point of Sale %s") % (session.name), @@ -19,24 +24,15 @@ def _prepare_from_pos(self, order_data): "user_id": order_data["user_id"], "pricelist_id": order_data["pricelist_id"], "fiscal_position_id": order_data["fiscal_position_id"], + "order_line": order_lines, } @api.model def create_order_from_pos(self, order_data, action): - SaleOrderLine = self.env["sale.order.line"] - # Create Draft Sale order order_vals = self._prepare_from_pos(order_data) sale_order = self.create(order_vals) - # create Sale order lines - for order_line_data in order_data["lines"]: - # Create Sale order lines - order_line_vals = SaleOrderLine._prepare_from_pos( - sale_order, order_line_data[2] - ) - SaleOrderLine.create(order_line_vals) - # Confirm Sale Order if action in ["confirmed", "delivered", "invoiced"]: sale_order.action_confirm() diff --git a/pos_order_to_sale_order/models/sale_order_line.py b/pos_order_to_sale_order/models/sale_order_line.py index db24df03e9..157f2badc0 100644 --- a/pos_order_to_sale_order/models/sale_order_line.py +++ b/pos_order_to_sale_order/models/sale_order_line.py @@ -9,14 +9,13 @@ class SaleOrderLine(models.Model): _inherit = "sale.order.line" @api.model - def _prepare_from_pos(self, sale_order, order_line_data): + def _prepare_from_pos(self, order_line_data): ProductProduct = self.env["product.product"] product = ProductProduct.browse(order_line_data["product_id"]) product_name = product.name if order_line_data.get("customer_note"): product_name += "\n" + order_line_data["customer_note"] return { - "order_id": sale_order.id, "product_id": order_line_data["product_id"], "name": product_name, "product_uom_qty": order_line_data["qty"],