-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9e4f7b
commit 7662147
Showing
14 changed files
with
645 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (C) 2025 - Today: GRAP (http://www.grap.coop) | ||
# @author: Quentin Dupont ([email protected]) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "MRP Food Menu Sale Order", | ||
"summary": "Create a sale order directly from your food menu.", | ||
"version": "16.0.1.0.0", | ||
"category": "GRAP - Custom", | ||
"author": "GRAP", | ||
"website": "https://github.com/grap/grap-odoo-custom", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"mrp_food_menu", | ||
"sale", | ||
], | ||
"data": [ | ||
"views/view_food_menu.xml", | ||
"views/view_sale_order.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_food_menu_sale_order | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2025-02-27 14:03+0000\n" | ||
"PO-Revision-Date: 2025-02-27 14:03+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mrp_food_menu_sale_order | ||
#: model_terms:ir.ui.view,arch_db:mrp_food_menu_sale_order.view_mrp_food_menu_sale_order_menu_form | ||
msgid "Create sale order" | ||
msgstr "Créer une vente" | ||
|
||
#. module: mrp_food_menu_sale_order | ||
#: model:ir.model.fields,field_description:mrp_food_menu_sale_order.field_sale_order__food_menu | ||
msgid "Food Menu" | ||
msgstr "Menu" | ||
|
||
#. module: mrp_food_menu_sale_order | ||
#: model:ir.model,name:mrp_food_menu_sale_order.model_mrp_food_menu | ||
msgid "Food menu" | ||
msgstr "Menu" | ||
|
||
#. module: mrp_food_menu_sale_order | ||
#: model:ir.model.fields,field_description:mrp_food_menu_sale_order.field_mrp_food_menu__sale_order | ||
msgid "Sale Order" | ||
msgstr "Bon de commande" | ||
|
||
#. module: mrp_food_menu_sale_order | ||
#: model:ir.model,name:mrp_food_menu_sale_order.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "Bon de commande" | ||
|
||
#. module: mrp_food_menu_sale_order | ||
#: model:ir.model.fields,help:mrp_food_menu_sale_order.field_mrp_food_menu__sale_order | ||
msgid "Theses sales were created from this menu." | ||
msgstr "Ces ventes ont été crée depuis un menu." | ||
|
||
#. module: mrp_food_menu_sale_order | ||
#: model:ir.model.fields,help:mrp_food_menu_sale_order.field_sale_order__food_menu | ||
msgid "This sale order was created from this menu." | ||
msgstr "Cette vente a été crée depuis ce menu." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import food_menu | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (C) 2025 - Today: GRAP (http://www.grap.coop) | ||
# @author: Quentin DUPONT ([email protected]) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class FoodMenu(models.Model): | ||
_inherit = "mrp.food.menu" | ||
|
||
sale_order_ids = fields.One2many( | ||
comodel_name="sale.order", | ||
help="Theses sales were created from this menu.", | ||
inverse_name="food_menu", | ||
readonly=True, | ||
) | ||
|
||
sale_order_count = fields.Integer( | ||
string="Sale orders", | ||
compute="_compute_sale_order_count", | ||
) | ||
|
||
# Action Section | ||
def create_sale_order_from_menu(self): | ||
self.ensure_one() | ||
sale_order_line = [] | ||
|
||
# Prepare sale.order.line with same order | ||
for line in sorted(self.menu_line_ids, key=lambda x: x.sequence): | ||
futur_order_line_vals = { | ||
"sequence": line.sequence, | ||
"display_type": line.display_type, | ||
"product_id": line.product_id.id, | ||
"name": line.product_id.name if line.product_id else line.name, | ||
"product_uom_qty": line.product_uom_qty, | ||
"product_uom": line.product_uom_id.id, | ||
"price_unit": line.product_id.list_price, | ||
} | ||
sale_order_line.append((0, 0, futur_order_line_vals)) | ||
|
||
# Return sale.order Form view with values | ||
return { | ||
"type": "ir.actions.act_window", | ||
"res_model": "sale.order", | ||
"view_mode": "form", | ||
"view_type": "form", | ||
"target": "current", | ||
"context": { | ||
"default_partner_id": False, | ||
"default_order_line": sale_order_line, | ||
"default_food_menu": self.id, | ||
}, | ||
} | ||
|
||
@api.depends("sale_order_ids") | ||
def _compute_sale_order_count(self): | ||
for food_menu in self: | ||
food_menu.sale_order_count = len(food_menu.sale_order_ids) | ||
|
||
def action_view_sale_order(self): | ||
return self._get_action_view_picking(self.picking_ids) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (C) 2025 - Today: GRAP (http://www.grap.coop) | ||
# @author: Quentin DUPONT ([email protected]) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
food_menu = fields.Many2one( | ||
comodel_name="mrp.food.menu", | ||
help="This sale order was created from this menu.", | ||
readonly=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Quentin Dupont ([email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Create a sale order directly from your food menu. |
Oops, something went wrong.