Skip to content

Commit

Permalink
17.0 mig sale force manual delivered (#16)
Browse files Browse the repository at this point in the history
* [17.0][MIG] sale_force_manual_delivered: Migration to 17.0

---------

Co-authored-by: GarethGloSystems <[email protected]>
Co-authored-by: Karl <[email protected]>
Co-authored-by: Kobby Folson <[email protected]>
  • Loading branch information
4 people authored Aug 22, 2024
1 parent 8f4cbe5 commit 079c298
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sale_force_manual_delivered/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sale_force_manual_delivered
---------------------------

Generalises force_manual_delivered_qty from TC's wwuk_sales_order

1 change: 1 addition & 0 deletions sale_force_manual_delivered/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions sale_force_manual_delivered/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "sale_forced_manual_delivered_qty",
"summary": "Allow forced manual delivery",
"author": "Glo Networks",
"website": "https://github.com/GlodoUK/sale",
"category": "Sales",
"version": "17.0.1.0.0",
"depends": ["sale_stock"],
"data": [
"views/sale_order.xml",
],
"license": "LGPL-3",
}
1 change: 1 addition & 0 deletions sale_force_manual_delivered/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
17 changes: 17 additions & 0 deletions sale_force_manual_delivered/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import api, fields, models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

force_manual_delivered_qty = fields.Boolean(default=False)

@api.depends("force_manual_delivered_qty", "is_expense", "state")
def _compute_qty_delivered_method(self):
res = super()._compute_qty_delivered_method()
for line in self.filtered(
lambda order_line: order_line.force_manual_delivered_qty
):
if line.force_manual_delivered_qty:
line.qty_delivered_method = "manual"
return res
3 changes: 3 additions & 0 deletions sale_force_manual_delivered/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions sale_force_manual_delivered/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_force_manual_delivered_qty
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from odoo.tests import tagged
from odoo.tests.common import TransactionCase


@tagged("post_install", "-at_install")
class TestForceManualDeliveredQty(TransactionCase):
def setUp(self):
super().setUp()

self.partner_id = self.env["res.partner"].create({"name": "Test Partner"})

self.product_id = self.env["product.product"].create({"name": "Product A"})

def test_force_manual_delivered_qty(self):
sale_order_id = self.env["sale.order"].create(
{
"partner_id": self.partner_id.id,
"order_line": [
(
0,
0,
{
"product_id": self.product_id.id,
"product_uom_qty": 1.0,
},
)
],
}
)
sale_order_id.order_line[0].force_manual_delivered_qty = True

self.assertEqual(sale_order_id.order_line[0].qty_delivered_method, "manual")
20 changes: 20 additions & 0 deletions sale_force_manual_delivered/views/sale_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version='1.0' encoding='utf-8' ?>
<odoo>
<record id="glodo_sale_view_order_form" model="ir.ui.view">
<field name="name">glodo_sale_view_order_form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='order_line']/tree//field[@name='qty_delivered']"
position="after"
>
<field
name="force_manual_delivered_qty"
string="Manual Delivered Qty"
column_invisible="parent.state in ['cancel','done']"
/>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 079c298

Please sign in to comment.