-
-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] pos_default_quantity: Migration to 16.0
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
- Loading branch information
1 parent
2c57c0c
commit 00dffb1
Showing
16 changed files
with
155 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from . import pos_config | ||
from . import pos_session | ||
from . import product_template | ||
from . import res_config_settings | ||
from . import uom_category |
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,14 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import models | ||
|
||
|
||
class PosSession(models.Model): | ||
_inherit = "pos.session" | ||
|
||
def _loader_params_product_product(self): | ||
result = super()._loader_params_product_product() | ||
result["search_params"]["fields"].append("pos_default_qty") | ||
return result |
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,11 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
pos_default_qty = fields.Float(related="uom_id.category_id.pos_default_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,14 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
pos_set_default_product_quantity = fields.Boolean( | ||
related="pos_config_id.set_default_product_quantity", | ||
readonly=False, | ||
) |
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,4 +1,4 @@ | ||
This module adds a field for a default quantity to Unit of Measure Categories. | ||
When this is filled in, and when this functionality is enabled in the Point of | ||
Sale Configuration, then adding that product to an order in the Point of Sale | ||
Sale configuration, then adding that product to an order in the Point of Sale | ||
will set the quantity to that value by default. |
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,8 @@ | ||
In order to set this up, you need to do a few things: | ||
|
||
- Make sure that you have permissions to manage multiple units of measure. | ||
- In the settings of Inventory, enable units of measure. | ||
- For each relevant unit of measure category, determine a default product quantity | ||
(default: 1). | ||
- For each relevant Point of Sale, find 'Set default product quantity' in the | ||
'Technical' section of its settings, and toggle it on. |
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,26 @@ | ||
/** @odoo-module alias=pos_default_quantity.models **/ | ||
// SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import {Orderline} from "point_of_sale.models"; | ||
import Registries from "point_of_sale.Registries"; | ||
|
||
const DefaultQtyOrderline = (Orderline) => | ||
class DefaultQtyOrderline extends Orderline { | ||
constructor(obj, options) { | ||
super(obj, options); | ||
|
||
// Don't set default quantity on restored lines | ||
if (options.json) { | ||
return; | ||
} | ||
|
||
if (this.pos.config.set_default_product_qty) { | ||
this.set_quantity(this.product.pos_default_qty); | ||
} | ||
} | ||
}; | ||
|
||
Registries.Model.extend(Orderline, DefaultQtyOrderline); | ||
export default DefaultQtyOrderline; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" ?> | ||
<odoo> | ||
<record id="res_config_settings_view_form" model="ir.ui.view"> | ||
<field | ||
name="name" | ||
>res.config.settings.view.form.inherit.pos_default_quantity</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@id='pos_technical_section']" position="inside"> | ||
<div class="col-12 col-lg-6 o_setting_box"> | ||
<div class="o_setting_left_pane"> | ||
<field name="pos_set_default_product_quantity" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="pos_set_default_product_quantity" /> | ||
<div class="text-muted"> | ||
When enabled, adding a product sets the quantity to | ||
a default configured on the Unit of Measure | ||
Category. | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |