@ -0,0 +1,49 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
Manufacturing Orders Splitting |
||||
|
============================== |
||||
|
This module allow to split manufacturing orders. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configurations needed |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
General Public License, Version 3 (AGPL v3). |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developers: (V16)Anagha C @ cybrosys, |
||||
|
(V17)Janish Babu EK @ cybrosys, |
||||
|
(V18)Ranjith R @ cybrosys, |
||||
|
Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import models |
||||
|
from . import wizard |
@ -0,0 +1,47 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
{ |
||||
|
'name': "Manufacturing Orders Splitting", |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Manufacturing', |
||||
|
'summary': """Manufacturing Orders Splitting by different methods""", |
||||
|
'description': """"Split manufacturing order from one order to |
||||
|
another manufacturing order on odoo system. this module |
||||
|
also helps to split order with the number of qty |
||||
|
& number of split manufacturing orders and split |
||||
|
manually by numbers""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.cybrosys.com", |
||||
|
'depends': ['mrp'], |
||||
|
'data': [ |
||||
|
'security/ir.model.access.csv', |
||||
|
'wizard/split_order_views.xml', |
||||
|
'views/mrp_production_views.xml', |
||||
|
], |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
## Module <split_mrp_order> |
||||
|
#### 19.02.2025 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
#### ADD |
||||
|
- Initial commit for Manufacturing Orders Splitting |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import mrp_production |
@ -0,0 +1,53 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import models, exceptions |
||||
|
|
||||
|
|
||||
|
class MrpProduction(models.Model): |
||||
|
""" Open wizard.""" |
||||
|
_inherit = 'mrp.production' |
||||
|
|
||||
|
def action_split_order(self): |
||||
|
""" Open wizard when click on 'split mo' button """ |
||||
|
if self.product_qty <= 1: |
||||
|
raise exceptions.UserError( |
||||
|
"Here, splitting is not possible. Enter enough quantity.") |
||||
|
|
||||
|
work_order = self.env.user.has_group('mrp.group_mrp_routings') |
||||
|
if work_order: |
||||
|
context = { |
||||
|
'default_order_id': self._origin.id, |
||||
|
'default_works': True |
||||
|
} |
||||
|
else: |
||||
|
context = { |
||||
|
'default_order_id': self._origin.id, |
||||
|
} |
||||
|
return { |
||||
|
'name': 'Split Order', |
||||
|
'res_model': 'split.order', |
||||
|
'view_mode': 'form', |
||||
|
'view_type': 'form', |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'target': 'new', |
||||
|
'context': context |
||||
|
} |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 767 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 760 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 697 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 186 KiB |
After Width: | Height: | Size: 198 KiB |
After Width: | Height: | Size: 130 KiB |
After Width: | Height: | Size: 176 KiB |
After Width: | Height: | Size: 194 KiB |
After Width: | Height: | Size: 192 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 178 KiB |
After Width: | Height: | Size: 164 KiB |
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 182 KiB |
After Width: | Height: | Size: 483 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 752 KiB |
After Width: | Height: | Size: 36 KiB |
@ -0,0 +1,16 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<odoo> |
||||
|
<!--Inherit mrp_production form--> |
||||
|
<record id="mrp_production_form_view" model="ir.ui.view"> |
||||
|
<field name="name">mrp.production.view.form.inherit.split.mrp.order</field> |
||||
|
<field name="model">mrp.production</field> |
||||
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//form/header/button[@name='button_mark_done']" |
||||
|
position="after"> |
||||
|
<button name="action_split_order" class="oe_highlight" |
||||
|
string="Split MO" type="object" invisible="state != 'draft'"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import split_order |
@ -0,0 +1,235 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
import math |
||||
|
import re |
||||
|
|
||||
|
from odoo import Command, fields, models |
||||
|
from odoo.exceptions import ValidationError |
||||
|
|
||||
|
|
||||
|
class SplitOrder(models.TransientModel): |
||||
|
""" Split manufacture order by different methods""" |
||||
|
_name = 'split.order' |
||||
|
_description = "Split Orders" |
||||
|
|
||||
|
splitting_method = fields.Selection([ |
||||
|
('by_no_of_quantity', 'By Number of Quantity'), |
||||
|
('by_no_of_split', 'By Number of Split'), |
||||
|
('split_manually', 'Split Manually')], string="Splitting Method", |
||||
|
required=True, help="To select splitting method") |
||||
|
no_of_quantity = fields.Integer(string="No of Quantity", |
||||
|
help="Number of quantity splitting") |
||||
|
no_of_split = fields.Integer(string="No of Split", |
||||
|
help="Number of splits quantity") |
||||
|
order_id = fields.Many2one('mrp.production', string="Order", |
||||
|
help="Manufacturing production order") |
||||
|
split_manually = fields.Char(string="Splitting Quantities", |
||||
|
help="Can split mrp manually") |
||||
|
work_center_id = fields.Many2one('mrp.workcenter', |
||||
|
string="Work Center", |
||||
|
required=True, help="work center") |
||||
|
works = fields.Boolean(string="Works", |
||||
|
help="For visible work center on wizard") |
||||
|
|
||||
|
def action_split_done(self): |
||||
|
""" Split by no of quantity,If no of quantity |
||||
|
is greater than product quantity no action required.""" |
||||
|
vals = { |
||||
|
'workcenter_id': self.work_center_id.id, |
||||
|
'product_uom_id': self.order_id.product_uom_id.id, |
||||
|
'name': self.work_center_id.name, |
||||
|
} |
||||
|
order = self.order_id |
||||
|
qty = order.product_qty |
||||
|
no_qty = self.no_of_quantity |
||||
|
no_split = self.no_of_split |
||||
|
manually = self.split_manually |
||||
|
if qty > 1 and no_qty: |
||||
|
if no_qty > qty: |
||||
|
raise ValidationError("Choose Valid Quantity") |
||||
|
elif no_qty == qty: |
||||
|
return False |
||||
|
else: |
||||
|
if order.move_raw_ids and not order.bom_id: |
||||
|
move_raw_ids_list = [] |
||||
|
for res in order.move_raw_ids: |
||||
|
uom = math.floor( |
||||
|
((1 / qty) * (qty - no_qty)) * res.product_uom_qty) |
||||
|
by_product_uom = res.product_uom_qty - uom |
||||
|
components = { |
||||
|
'product_id': res.product_id.id, |
||||
|
'product_uom_qty': uom |
||||
|
} |
||||
|
res.update(components) |
||||
|
move_raw_ids_list.append({ |
||||
|
'product_id': res.product_id.id, |
||||
|
'product_uom_qty': abs(by_product_uom) |
||||
|
}) |
||||
|
self.env['mrp.production'].create({ |
||||
|
'product_qty': no_qty, |
||||
|
'product_id': order.product_id.id, |
||||
|
'product_uom_id': order.product_uom_id.id, |
||||
|
'move_raw_ids': [Command.create(data) for data in |
||||
|
move_raw_ids_list], |
||||
|
}) |
||||
|
order.write( |
||||
|
{ |
||||
|
'product_qty': qty - no_qty, |
||||
|
}) |
||||
|
else: |
||||
|
order.write( |
||||
|
{ |
||||
|
'product_qty': qty - no_qty, |
||||
|
'workorder_ids': [Command.create(vals)] |
||||
|
}) |
||||
|
self.env['mrp.production'].create({ |
||||
|
'product_qty': no_qty, |
||||
|
'product_id': order.product_id.id, |
||||
|
'product_uom_id': order.product_uom_id.id, |
||||
|
}) |
||||
|
"""Split manufacture order by no of splits,If no of quantity |
||||
|
is greater than product quantity no action required.""" |
||||
|
if qty > 1 and no_split: |
||||
|
if no_split > qty: |
||||
|
raise ValidationError("Choose Valid Quantity") |
||||
|
elif no_split == qty: |
||||
|
return False |
||||
|
else: |
||||
|
split = qty // no_split |
||||
|
reminder = qty % no_split |
||||
|
value = qty - reminder |
||||
|
if order.move_raw_ids and not order.bom_id: |
||||
|
mrp_order=False |
||||
|
if value == 0: |
||||
|
return False |
||||
|
else: |
||||
|
for val in range(int(split)): |
||||
|
move_raw_ids_list = [] |
||||
|
for rec in order.move_raw_ids: |
||||
|
by_product_split = rec.product_uom_qty // no_split |
||||
|
by_product_reminder = rec.product_uom_qty % no_split |
||||
|
by_product_value = rec.product_uom_qty - by_product_reminder |
||||
|
by_product_split_qty = by_product_value // by_product_split |
||||
|
move_raw_ids_list.append({ |
||||
|
'product_id': rec.product_id.id, |
||||
|
'product_uom_qty': by_product_split_qty |
||||
|
}) |
||||
|
mrp_order=self.env[ |
||||
|
'mrp.production'].create( |
||||
|
{ |
||||
|
'product_qty': value // split, |
||||
|
'product_id': order.product_id.id, |
||||
|
'workorder_ids': [Command.create(vals)], |
||||
|
'move_raw_ids': [Command.create(data) |
||||
|
for data in |
||||
|
move_raw_ids_list], |
||||
|
}) |
||||
|
if reminder > 0: |
||||
|
order.write( |
||||
|
{ |
||||
|
'product_qty': reminder, |
||||
|
'workorder_ids': [Command.create(vals)] |
||||
|
}) |
||||
|
else: |
||||
|
order.unlink() |
||||
|
if mrp_order: |
||||
|
return { |
||||
|
"type": "ir.actions.act_window", |
||||
|
"res_model": "mrp.production", |
||||
|
"res_id": mrp_order.id, |
||||
|
"view_mode": "form", |
||||
|
"views": [[False, "form"]], |
||||
|
"target": "current", |
||||
|
} |
||||
|
else: |
||||
|
split = qty // no_split |
||||
|
reminder = qty % no_split |
||||
|
value = qty - reminder |
||||
|
if value == 0: |
||||
|
return False |
||||
|
else: |
||||
|
for val in range(int(split)): |
||||
|
create_mo_split = self.env['mrp.production'].create( |
||||
|
{ |
||||
|
'product_qty': value // split, |
||||
|
'product_id': order.product_id.id |
||||
|
}) |
||||
|
create_mo_split.write( |
||||
|
{'workorder_ids': [Command.create(vals)]}) |
||||
|
if reminder > 0: |
||||
|
order.write( |
||||
|
{ |
||||
|
'product_qty': reminder, |
||||
|
'workorder_ids': [Command.create(vals)] |
||||
|
}) |
||||
|
else: |
||||
|
order.unlink() |
||||
|
""" Split manufacture order by Manually""" |
||||
|
if qty > 1 and manually: |
||||
|
split_value = manually.split(",") |
||||
|
total = sum(map(int, split_value)) |
||||
|
split_sum = 0 |
||||
|
val = [] |
||||
|
split_manually = self.split_manually |
||||
|
pattern = r'^[\d,]+$' |
||||
|
validation = re.match(pattern, split_manually) is not None |
||||
|
if total<qty: |
||||
|
raise ValidationError("The total of split must be equal to the order quantity") |
||||
|
if validation: |
||||
|
for rec in split_value: |
||||
|
split_sum += int(rec) |
||||
|
val.append(int(rec)) |
||||
|
for record in val: |
||||
|
if record == 0: |
||||
|
val.remove(0) |
||||
|
if split_sum > qty or split_sum == 0: |
||||
|
raise ValidationError("Choose Valid Quantity") |
||||
|
if order.move_raw_ids and not order.bom_id: |
||||
|
for rec in val: |
||||
|
move_raw_ids_list = [] |
||||
|
for c in order.move_raw_ids: |
||||
|
move_raw_ids_list.append({ |
||||
|
'product_id': c.product_id.id, |
||||
|
'product_uom_qty': round( |
||||
|
(1 / split_sum) * c.product_uom_qty * rec) |
||||
|
}) |
||||
|
self.env['mrp.production'].create({ |
||||
|
'product_qty': int(rec), |
||||
|
'product_id': order.product_id.id, |
||||
|
'move_raw_ids': [Command.create(data) for data in |
||||
|
move_raw_ids_list], |
||||
|
}) |
||||
|
order.unlink() |
||||
|
else: |
||||
|
order.write( |
||||
|
{ |
||||
|
'product_qty': int(val[0]), |
||||
|
'workorder_ids': [Command.create(vals)], |
||||
|
}) |
||||
|
val.pop(0) |
||||
|
for rec in val: |
||||
|
self.env['mrp.production'].create({ |
||||
|
'product_qty': int(rec), |
||||
|
'product_id': order.product_id.id |
||||
|
}) |
||||
|
else: |
||||
|
raise ValidationError("Enter the correct value") |