[MIG] sale_order_add_bom from v10 to v14
This commit is contained in:
committed by
Alexis de Lattre
parent
371229e9e5
commit
f6b10a7caa
@@ -1,4 +1,2 @@
|
|||||||
# -*- coding: utf-8 -*-
|
from . import models
|
||||||
|
|
||||||
from . import mrp_bom
|
|
||||||
from . import wizard
|
from . import wizard
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2016-2022 Akretion France (http://www.akretion.com/)
|
||||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Sale Order Add Bom',
|
'name': 'Sale Order Add Bom',
|
||||||
'version': '10.0.1.0.0',
|
'version': '14.0.1.0.0',
|
||||||
'category': 'Sales',
|
'category': 'Sales',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Wizard to select a bom from a sale order',
|
'summary': 'Wizard to select a bom from a sale order',
|
||||||
@@ -17,12 +17,13 @@ This module has been written by Alexis de Lattre from Akretion
|
|||||||
<alexis.delattre@akretion.com>.
|
<alexis.delattre@akretion.com>.
|
||||||
""",
|
""",
|
||||||
'author': 'Akretion',
|
'author': 'Akretion',
|
||||||
'website': 'http://www.akretion.com',
|
'website': 'https://github.com/akretion/odoo-usability',
|
||||||
'depends': ['sale', 'mrp'],
|
'depends': ['sale', 'mrp'],
|
||||||
'data': [
|
'data': [
|
||||||
'wizard/sale_add_phantom_bom_view.xml',
|
'wizard/sale_add_phantom_bom_view.xml',
|
||||||
'views/sale_order.xml',
|
'views/sale_order.xml',
|
||||||
'views/stock_picking.xml',
|
'views/stock_picking.xml',
|
||||||
|
'security/ir.model.access.csv',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|||||||
1
sale_order_add_bom/models/__init__.py
Normal file
1
sale_order_add_bom/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import mrp_bom
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2016-2022 Akretion France (http://www.akretion.com/)
|
||||||
# Copyright 2016-2019 Akretion France
|
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
@@ -8,6 +7,5 @@ from odoo import models, fields
|
|||||||
|
|
||||||
class MrpBom(models.Model):
|
class MrpBom(models.Model):
|
||||||
_inherit = 'mrp.bom'
|
_inherit = 'mrp.bom'
|
||||||
# _rec_name = 'product_id'
|
|
||||||
|
|
||||||
sale_ok = fields.Boolean(related='product_tmpl_id.sale_ok', store=True)
|
sale_ok = fields.Boolean(related='product_tmpl_id.sale_ok', store=True)
|
||||||
3
sale_order_add_bom/security/ir.model.access.csv
Normal file
3
sale_order_add_bom/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_sale_add_phantom_bom_sale,Full access on sale.add.phantom.bom wizard to sale user,model_sale_add_phantom_bom,sales_team.group_sale_salesman,1,1,1,1
|
||||||
|
access_sale_add_phantom_bom_stock,Full access on sale.add.phantom.bom wizard to stock user,model_sale_add_phantom_bom,stock.group_stock_user,1,1,1,1
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright 2016-2021 Akretion France (http://www.akretion.com/)
|
Copyright 2016-2022 Akretion France (http://www.akretion.com/)
|
||||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
|
||||||
|
|
||||||
<record id="view_order_form" model="ir.ui.view">
|
<record id="view_order_form" model="ir.ui.view">
|
||||||
<field name="name">add.bom.sale.order.form</field>
|
<field name="name">add.bom.sale.order.form</field>
|
||||||
@@ -20,5 +19,4 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright 2021 Akretion France (http://www.akretion.com/)
|
Copyright 2021-2022 Akretion France (http://www.akretion.com/)
|
||||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import sale_add_phantom_bom
|
from . import sale_add_phantom_bom
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2016-2022 Akretion France (http://www.akretion.com/)
|
||||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from openerp.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
from openerp.tools import float_is_zero
|
from odoo.tools import float_is_zero
|
||||||
|
|
||||||
|
|
||||||
class SaleAddPhantomBom(models.TransientModel):
|
class SaleAddPhantomBom(models.TransientModel):
|
||||||
@@ -13,11 +13,15 @@ class SaleAddPhantomBom(models.TransientModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields_list):
|
def default_get(self, fields_list):
|
||||||
res = super(SaleAddPhantomBom, self).default_get(fields_list)
|
res = super().default_get(fields_list)
|
||||||
if self._context.get('active_model') == 'sale.order':
|
if self._context.get('active_model') == 'sale.order':
|
||||||
res['sale_id'] = self._context['active_id']
|
res['sale_id'] = self._context['active_id']
|
||||||
|
sale = self.env['sale.order'].browse(res['sale_id'])
|
||||||
|
res['company_id'] = sale.company_id.id
|
||||||
elif self._context.get('active_model') == 'stock.picking':
|
elif self._context.get('active_model') == 'stock.picking':
|
||||||
res['picking_id'] = self._context['active_id']
|
res['picking_id'] = self._context['active_id']
|
||||||
|
picking = self.env['stock.picking'].browse(res['picking_id'])
|
||||||
|
res['company_id'] = picking.company_id.id
|
||||||
else:
|
else:
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
"The wizard can only be started from a sale order or a picking."))
|
"The wizard can only be started from a sale order or a picking."))
|
||||||
@@ -25,7 +29,8 @@ class SaleAddPhantomBom(models.TransientModel):
|
|||||||
|
|
||||||
bom_id = fields.Many2one(
|
bom_id = fields.Many2one(
|
||||||
'mrp.bom', 'Kit', required=True,
|
'mrp.bom', 'Kit', required=True,
|
||||||
domain=[('type', '=', 'phantom'), ('sale_ok', '=', True)])
|
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id), ('type', '=', 'phantom'), ('sale_ok', '=', True)]")
|
||||||
|
company_id = fields.Many2one('res.company', string='Company', required=True)
|
||||||
qty = fields.Integer(
|
qty = fields.Integer(
|
||||||
string='Number of Kits to Add', default=1, required=True)
|
string='Number of Kits to Add', default=1, required=True)
|
||||||
sale_id = fields.Many2one(
|
sale_id = fields.Many2one(
|
||||||
@@ -63,7 +68,6 @@ class SaleAddPhantomBom(models.TransientModel):
|
|||||||
}
|
}
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def add(self):
|
def add(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
assert self.sale_id or self.picking_id, 'No related sale_id or picking_id'
|
assert self.sale_id or self.picking_id, 'No related sale_id or picking_id'
|
||||||
@@ -90,4 +94,3 @@ class SaleAddPhantomBom(models.TransientModel):
|
|||||||
elif self.picking_id:
|
elif self.picking_id:
|
||||||
vals = self._prepare_stock_move(line, self.picking_id, self.qty)
|
vals = self._prepare_stock_move(line, self.picking_id, self.qty)
|
||||||
smo.create(vals)
|
smo.create(vals)
|
||||||
return True
|
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
Copyright 2016-2022 Akretion France (http://www.akretion.com/)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
|
||||||
|
|
||||||
<record id="sale_add_phantom_bom_form" model="ir.ui.view">
|
<record id="sale_add_phantom_bom_form" model="ir.ui.view">
|
||||||
<field name="name">sale.add.phantom.bom.form</field>
|
<field name="name">sale.add.phantom.bom.form</field>
|
||||||
<field name="model">sale.add.phantom.bom</field>
|
<field name="model">sale.add.phantom.bom</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Add Phantom BOM to the Quotation">
|
<form>
|
||||||
<group name="main">
|
<group name="main">
|
||||||
|
<field name="sale_id" invisible="1"/>
|
||||||
|
<field name="picking_id" invisible="1"/>
|
||||||
|
<field name="company_id" invisible="1"/>
|
||||||
<field name="bom_id" default_focus="1"/>
|
<field name="bom_id" default_focus="1"/>
|
||||||
<field name="qty"/>
|
<field name="qty"/>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="add" type="object"
|
<button name="add" type="object"
|
||||||
class="oe_highlight" string="Add"/>
|
class="btn-primary" string="Add"/>
|
||||||
<button special="cancel" string="Cancel" class="oe_link"/>
|
<button special="cancel" string="Cancel"/>
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
@@ -32,5 +35,4 @@
|
|||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user