-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
78 additions
and
0 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
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,15 @@ | ||
{ | ||
"name": "Sale deliver service as goods", | ||
"summary": "Ship goods and set service products as delivered", | ||
"version": "18.0.1.0.0", | ||
"author": "Akretion", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"sale_stock", | ||
], | ||
"exclude": ["sms"], | ||
"data": [ | ||
"views/sale.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 @@ | ||
from . import sale |
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,43 @@ | ||
from odoo import fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
# Used to display ui_ship_all_products | ||
available_case = fields.Boolean(compute="_compute_available_case") | ||
|
||
def _compute_available_case(self): | ||
for rec in self: | ||
pick = rec.picking_ids and rec.picking_ids[0] | ||
if rec.state == "sale" and ( | ||
not pick | ||
or ( | ||
len(pick) == 1 | ||
and pick.state != "done" | ||
and pick.products_availability_state == "available" | ||
) | ||
): | ||
rec.available_case = True | ||
else: | ||
rec.available_case = False | ||
|
||
def ui_ship_all_products_c(self): | ||
for rec in self: | ||
# TODO check combo | ||
pick = rec.picking_ids and rec.picking_ids[0] | ||
if pick: | ||
if pick == "waiting": | ||
pick.action_assign() | ||
try: | ||
pick.with_context(skip_sms=True).button_validate() | ||
except Exception as err: | ||
raise UserError(err) from err | ||
if pick.state != "done": | ||
# breakpoint() # import pdb; pdb.set_trace() | ||
raise UserError("Problème sur le transfert") | ||
for line in rec.order_line.filtered( | ||
lambda s: s.product_id.type == "service" | ||
): | ||
line.qty_delivered = line.product_uom_qty |
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,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
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 @@ | ||
<odoo> | ||
|
||
<record id="view_order_form" model="ir.ui.view"> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//button[last()]" position="after"> | ||
<button name="ui_ship_all_products_c" string="🚚 Livrer" type="object" | ||
invisible="not available_case" | ||
title="Livre directement tous les produits de la vente quand cela est possible" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |