-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update sale_quotation and add shopinvader_sale_state
- Loading branch information
matthieu.saison
committed
Nov 27, 2023
1 parent
6a8dde2
commit e667997
Showing
10 changed files
with
59 additions
and
96 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# @author Benoît GUILLOT <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo import _, fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
@@ -14,27 +15,8 @@ class SaleOrder(models.Model): | |
selection_add=[("quotation", "Quotation")], | ||
ondelete={"quotation": "cascade"}, | ||
) | ||
shopinvader_state = fields.Selection( | ||
selection_add=[ | ||
("estimating", "Estimating Quotation"), | ||
("estimated", "Estimated Quotation"), | ||
], | ||
ondelete={ | ||
"estimating": "cascade", | ||
"estimated": "cascade", | ||
}, | ||
) | ||
|
||
def _compute_shopinvader_state_depends(self): | ||
return super()._compute_shopinvader_state_depends() + ("typology",) | ||
|
||
def _get_shopinvader_state(self): | ||
self.ensure_one() | ||
if self.typology == "quotation" and self.state == "draft": | ||
return "estimating" | ||
if self.typology == "quotation" and self.state == "sent": | ||
return "estimated" | ||
return super()._get_shopinvader_state() | ||
available_for_quotation = fields.Boolean(compute="_compute_available_for_quotation") | ||
shop_only_quotation = fields.Boolean(compute="_compute_shop_only_quotation") | ||
|
||
def action_request_quotation(self): | ||
if any(rec.state != "draft" or rec.typology != "cart" for rec in self): | ||
|
@@ -46,15 +28,18 @@ def action_request_quotation(self): | |
) | ||
for rec in self: | ||
rec.typology = "quotation" | ||
if rec.shopinvader_backend_id: | ||
rec.shopinvader_backend_id._send_notification("quotation_request", rec) | ||
return True | ||
|
||
def write(self, vals): | ||
# Set the typology to "quotation" when the quotation is sent. | ||
# Normally there are two cases where this happens: | ||
# * When the :meth:`action_quotation_sent` is called. | ||
# * When a message is posted with context `mark_so_as_sent=True`. | ||
if vals.get("state") == "sent": | ||
vals["typology"] = "quotation" | ||
return super().write(vals) | ||
return self | ||
|
||
def _compute_available_for_quotation(self): | ||
for record in self: | ||
record.available_for_quotation = True | ||
|
||
def _compute_shop_only_quotation(self): | ||
for record in self: | ||
record.shop_only_quotation = any( | ||
record.order_line.product_id.mapped("shop_only_quotation") | ||
) | ||
|
||
def action_confirm_quotation(self): | ||
self.typology = "sale" | ||
return self.action_confirm() |
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
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 test_product |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,17 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
|
||
<record id="view_product_template_form" model="ir.ui.view"> | ||
<record id="product_template_form_view" model="ir.ui.view"> | ||
<field name="model">product.template</field> | ||
<field name="inherit_id" ref="shopinvader.view_product_template_form" /> | ||
<field name="inherit_id" ref="product.product_template_form_view" /> | ||
<field name="arch" type="xml"> | ||
<group name="shopinvader_options" position="attributes"> | ||
<attribute name="invisible">0</attribute> | ||
</group> | ||
<group name="shopinvader_options" position="inside"> | ||
<field name="categ_id" position="after"> | ||
<field name="shop_only_quotation" string="Only for Quotation" /> | ||
</group> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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