[imp] added basic wizard
TODO: add return methode
This commit is contained in:
parent
1bdf0f3c2f
commit
6ff1bbb45d
10 changed files with 39 additions and 43 deletions
|
|
@ -1,2 +1,3 @@
|
||||||
from . import models
|
from . import models
|
||||||
from . import controllers
|
from . import controllers
|
||||||
|
from . import wizard
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,10 @@
|
||||||
"data": [
|
"data": [
|
||||||
"views/sale_order_views.xml",
|
"views/sale_order_views.xml",
|
||||||
"views/sale_order_line_views.xml",
|
"views/sale_order_line_views.xml",
|
||||||
'views/templates.xml',
|
"wizard/sale_max_qty_chooser_views.xml",
|
||||||
|
"views/templates.xml",
|
||||||
|
"security/ir.model.access.csv",
|
||||||
],
|
],
|
||||||
'assets': {
|
"assets": {"web.assets_frontend": ["nfu_sale_product_min_max_qty/static/src/js/website_sale.js"]},
|
||||||
"web.assets_frontend": [
|
|
||||||
"nfu_sale_product_min_max_qty/static/src/js/website_sale.js"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -9,36 +7,31 @@ class SaleOrder(models.Model):
|
||||||
def action_min_max_qty_wizard(self):
|
def action_min_max_qty_wizard(self):
|
||||||
"""
|
"""
|
||||||
Here you need to create the wizzard objects first and then call the wizzard with the newly created id
|
Here you need to create the wizzard objects first and then call the wizzard with the newly created id
|
||||||
|
"""
|
||||||
sale_order_lines = self.env[sale.order.line].search[id in self.order_line.ids]
|
|
||||||
|
|
||||||
sale_max_qty_chooser = self.env["sale.max.qty.chooser"].create({})
|
sale_max_qty_chooser = self.env["sale.max.qty.chooser"].create({})
|
||||||
|
draft_sale_orders = self.filtered(lambda x: x.state == "draft")
|
||||||
|
for sale_order in draft_sale_orders:
|
||||||
|
sale_order_lines = self.env["sale.order.line"].search([("id", "in", sale_order.order_line.ids)])
|
||||||
|
|
||||||
for line in sale_order_lines:
|
for line in sale_order_lines:
|
||||||
if not display_type:
|
if not line.display_type:
|
||||||
sale_max_qty_line = self.env["sale.max.qty.line"].create({"sale_line_id": self.id,
|
self.env["sale.max.qty.line"].create(
|
||||||
"sale_max_qty_chooser": sale_max_qty_chooser,
|
{
|
||||||
"qty": ....
|
"sale_line_id": line.id,
|
||||||
|
"sale_max_qty_chooser": sale_max_qty_chooser.id,
|
||||||
})
|
"qty": line.product_uom_qty,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
"name": _("Min max qty wizard"),
|
|
||||||
"type": "ir.actions.act_window",
|
|
||||||
"res_model": "sale.max.qty.chooser",
|
|
||||||
"view_mode": "form",
|
|
||||||
"target": "new",
|
|
||||||
"res_id": sale_max_qty_chooser.id,
|
|
||||||
}
|
|
||||||
return action
|
|
||||||
"""
|
|
||||||
return {
|
|
||||||
"name": _("Min max qty wizard"),
|
"name": _("Min max qty wizard"),
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"res_model": "sale.order.line",
|
"res_model": "sale.max.qty.chooser",
|
||||||
"view_mode": "tree,form",
|
"view_mode": "form",
|
||||||
"domain": [("id", "in", self.order_line.ids)],
|
"target": "new",
|
||||||
|
"res_id": sale_max_qty_chooser.id,
|
||||||
}
|
}
|
||||||
|
return action
|
||||||
|
|
||||||
def _prepare_order_line_values(
|
def _prepare_order_line_values(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from odoo import models, fields, api
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
class SaleOrderLine(models.Model):
|
class SaleOrderLine(models.Model):
|
||||||
|
|
@ -11,5 +11,5 @@ class SaleOrderLine(models.Model):
|
||||||
@api.constrains("product_uom_qty", "product_uom_max_qty")
|
@api.constrains("product_uom_qty", "product_uom_max_qty")
|
||||||
def _check_product_uom_qty(self):
|
def _check_product_uom_qty(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.product_uom_qty > record.product_uom_max_qty:
|
if record.product_uom_max_qty != 0 and record.product_uom_qty > record.product_uom_max_qty:
|
||||||
raise ValidationError("The quantity must be less than or equal to the maximum quantity.")
|
raise UserError(_("The quantity must be less than or equal to the maximum quantity."))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_sale_max_qty_chooser,sale.max.qty.chooser,model_sale_max_qty_chooser,sales_team.group_sale_salesman,1,1,1,1
|
||||||
|
access_sale_max_qty_line,sale.max.qty.line,model_sale_max_qty_line,sales_team.group_sale_salesman,1,1,1,1
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<field name="name">sale.order.line.tree</field>
|
<field name="name">sale.order.line.tree</field>
|
||||||
<field name="model">sale.order.line</field>
|
<field name="model">sale.order.line</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Sales Order Lines" create="false">
|
<tree create="false">
|
||||||
<field name="order_id"/>
|
<field name="order_id"/>
|
||||||
<field name="order_partner_id"/>
|
<field name="order_partner_id"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
|
|
||||||
2
nfu_sale_product_min_max_qty/wizard/__init__.py
Normal file
2
nfu_sale_product_min_max_qty/wizard/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
from . import sale_max_qty_chooser
|
||||||
|
from . import sale_max_qty_line
|
||||||
|
|
@ -8,10 +8,10 @@ class SaleMaxQtyChooser(models.TransientModel):
|
||||||
_description = "Sale Max Quantity Chhooser"
|
_description = "Sale Max Quantity Chhooser"
|
||||||
|
|
||||||
# fill from init or compute from given sale order lines
|
# fill from init or compute from given sale order lines
|
||||||
sale_order_ids = fields.Many2many("sale.order")
|
# sale_order_ids = fields.Many2many("sale.order")
|
||||||
sale_max_qty_ids = fields.One2many("sale.max.qty.line", "mrp_return_id")
|
sale_max_qty_ids = fields.One2many("sale.max.qty.line", "sale_max_qty_chooser")
|
||||||
|
|
||||||
def confirm_qty_sale_order(self):
|
def update_and_confirm_sale_order(self):
|
||||||
"""
|
"""
|
||||||
Confirm sale orders where the quantity is fine. Create new Sale Orders for SO Lines with reset to draft
|
Confirm sale orders where the quantity is fine. Create new Sale Orders for SO Lines with reset to draft
|
||||||
Through user error when total order amount of a product is not equal to packaging size (first package in the
|
Through user error when total order amount of a product is not equal to packaging size (first package in the
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
</div>
|
</div>
|
||||||
<field name="sale_max_qty_ids">
|
<field name="sale_max_qty_ids">
|
||||||
<tree create="0">
|
<tree create="0">
|
||||||
<!-- Make this field read only -->
|
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="qty"/>
|
<field name="qty"/>
|
||||||
<field name="reset_to_draft"/>
|
<field name="reset_to_draft"/>
|
||||||
|
|
@ -19,7 +18,7 @@
|
||||||
</field>
|
</field>
|
||||||
<footer>
|
<footer>
|
||||||
<button
|
<button
|
||||||
name="confirm_qty_sale_order"
|
name="update_and_confirm_sale_order"
|
||||||
string="Confirm Sale Orders"
|
string="Confirm Sale Orders"
|
||||||
type="object"
|
type="object"
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
Loading…
Reference in a new issue