-
-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] mrp_subcontracting_purchase: Adapt to OCA guidelines + initial …
…work
- Loading branch information
Showing
12 changed files
with
118 additions
and
73 deletions.
There are no files selected for viewing
Empty file.
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,3 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import models |
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,19 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
{ | ||
'name': 'Purchase and Subcontracting Management', | ||
'version': '0.1', | ||
'category': 'Manufacturing/Purchase', | ||
'description': """ | ||
"name": "Purchase and Subcontracting Management", | ||
"version": "14.0.1.0.0", | ||
"category": "Manufacturing/Purchase", | ||
"summary": """ | ||
This bridge module adds some smart buttons between Purchase and Subcontracting | ||
""", | ||
'depends': ['mrp_subcontracting', 'purchase'], | ||
'data': [ | ||
'views/purchase_order_views.xml', | ||
'views/stock_picking_views.xml', | ||
"author": "Odoo S.A., Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/manufacture", | ||
"depends": ["mrp_subcontracting", "purchase"], | ||
"data": [ | ||
"views/purchase_order_views.xml", | ||
"views/stock_picking_views.xml", | ||
], | ||
'installable': True, | ||
'auto_install': True, | ||
'license': 'LGPL-3', | ||
"installable": True, | ||
"auto_install": True, | ||
"license": "LGPL-3", | ||
} |
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,25 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models, fields, api | ||
from odoo import api, fields, models | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = 'purchase.order' | ||
_inherit = "purchase.order" | ||
|
||
subcontracting_resupply_picking_count = fields.Integer( | ||
"Count of Subcontracting Resupply", compute='_compute_subcontracting_resupply_picking_count', | ||
help="Count of Subcontracting Resupply for component") | ||
"Count of Subcontracting Resupply", | ||
compute="_compute_subcontracting_resupply_picking_count", | ||
help="Count of Subcontracting Resupply for component", | ||
) | ||
|
||
@api.depends('order_line.move_ids') | ||
@api.depends("order_line.move_ids") | ||
def _compute_subcontracting_resupply_picking_count(self): | ||
for purchase in self: | ||
purchase.subcontracting_resupply_picking_count = len(purchase._get_subcontracting_resupplies()) | ||
purchase.subcontracting_resupply_picking_count = len( | ||
purchase._get_subcontracting_resupplies() | ||
) | ||
|
||
def action_view_subcontracting_resupply(self): | ||
return self._get_action_view_picking(self._get_subcontracting_resupplies()) | ||
|
||
def _get_subcontracting_resupplies(self): | ||
moves_subcontracted = self.order_line.move_ids.filtered(lambda m: m.is_subcontract) | ||
moves_subcontracted = self.order_line.move_ids.filtered( | ||
lambda m: m.is_subcontract | ||
) | ||
subcontracted_productions = moves_subcontracted.move_orig_ids.production_id | ||
return subcontracted_productions.picking_ids |
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,40 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models, fields, api, _ | ||
from odoo import _, api, fields, models | ||
|
||
|
||
class StockPicking(models.Model): | ||
_inherit = 'stock.picking' | ||
_inherit = "stock.picking" | ||
|
||
subcontracting_source_purchase_count = fields.Integer( | ||
"Number of subcontracting PO Source", compute='_compute_subcontracting_source_purchase_count', | ||
help="Number of subcontracting Purchase Order Source") | ||
"Number of subcontracting PO Source", | ||
compute="_compute_subcontracting_source_purchase_count", | ||
help="Number of subcontracting Purchase Order Source", | ||
) | ||
|
||
@api.depends('move_lines.move_dest_ids.raw_material_production_id') | ||
@api.depends("move_lines.move_dest_ids.raw_material_production_id") | ||
def _compute_subcontracting_source_purchase_count(self): | ||
for picking in self: | ||
picking.subcontracting_source_purchase_count = len(picking._get_subcontracting_source_purchase()) | ||
picking.subcontracting_source_purchase_count = len( | ||
picking._get_subcontracting_source_purchase() | ||
) | ||
|
||
def action_view_subcontracting_source_purchase(self): | ||
purchase_order_ids = self._get_subcontracting_source_purchase().ids | ||
action = { | ||
'res_model': 'purchase.order', | ||
'type': 'ir.actions.act_window', | ||
"res_model": "purchase.order", | ||
"type": "ir.actions.act_window", | ||
} | ||
if len(purchase_order_ids) == 1: | ||
action.update({ | ||
'view_mode': 'form', | ||
'res_id': purchase_order_ids[0], | ||
}) | ||
action.update( | ||
{ | ||
"view_mode": "form", | ||
"res_id": purchase_order_ids[0], | ||
} | ||
) | ||
else: | ||
action.update({ | ||
'name': _("Source PO of %s", self.name), | ||
'domain': [('id', 'in', purchase_order_ids)], | ||
'view_mode': 'tree,form', | ||
}) | ||
action.update( | ||
{ | ||
"name": _("Source PO of %s", self.name), | ||
"domain": [("id", "in", purchase_order_ids)], | ||
"view_mode": "tree,form", | ||
} | ||
) | ||
return action | ||
|
||
def _get_subcontracting_source_purchase(self): | ||
moves_subcontracted = self.move_lines.move_dest_ids.raw_material_production_id.move_finished_ids.move_dest_ids.filtered(lambda m: m.is_subcontract) | ||
moves_subcontracted = self.move_lines.move_dest_ids.raw_material_production_id.move_finished_ids.move_dest_ids.filtered( # noqa | ||
lambda m: m.is_subcontract | ||
) | ||
return moves_subcontracted.purchase_line_id.order_id |
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,3 +1 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import test_mrp_subcontracting_purchase |
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
28 changes: 20 additions & 8 deletions
28
mrp_subcontracting_purchase/views/purchase_order_views.xml
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
1 change: 1 addition & 0 deletions
1
setup/mrp_subcontracting_purchase/odoo/addons/mrp_subcontracting_purchase
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 @@ | ||
../../../../mrp_subcontracting_purchase |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |