forked from OCA/hr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OCA#70 from gurneyalex/fix_interco
add specific inter company
- Loading branch information
Showing
11 changed files
with
147 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
---------------------- | ||
specific inter company | ||
---------------------- | ||
|
||
|
||
This module handles the specifics of intercompany rules for Roctool: | ||
|
||
* the sale orders have some additional required fields => we provide some | ||
values from them when a SO is created from a PO. |
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 @@ | ||
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Author: Alexandre Fayolle | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "RocTool specific inter company rules", | ||
"version": "10.0.1.0.0", | ||
"depends": [ | ||
"inter_company_rules", | ||
"specific_sale", | ||
], | ||
"author": "Camptocamp,Odoo Community Association (OCA)", | ||
"website": "http://www.camptocamp.com", | ||
"license": "GPL-3 or any later version", | ||
"category": "Sale", | ||
"data": [ | ||
], | ||
'installable': True, | ||
} |
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 @@ | ||
from . import purchase_order |
53 changes: 53 additions & 0 deletions
53
odoo/local-src/specific_inter_company/models/purchase_order.py
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,53 @@ | ||
# -*- coding: utf-8 -*- | ||
# Author: Damien Crier | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
import base64 | ||
|
||
from odoo import models, api, _ | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = 'purchase.order' | ||
|
||
@api.one | ||
def _prepare_sale_order_data(self, name, partner, company, | ||
direct_delivery_address): | ||
values = super(PurchaseOrder, self)._prepare_sale_order_data( | ||
name, partner, company, direct_delivery_address | ||
)[0] | ||
analytic = self.mapped('order_line.account_analytic_id') | ||
if len(analytic) != 1: | ||
raise UserError(_('All the lines of the purchase must ' | ||
'be on the same analytic account')) | ||
if not analytic.project_zone_id: | ||
raise UserError( | ||
_('The analytic account %s ' | ||
'does not have a Project Zone') % analytic.name | ||
) | ||
if not analytic.project_process_id: | ||
raise UserError( | ||
_('The analytic account %s ' | ||
'does not have a Project Process') % analytic.name | ||
) | ||
if not analytic.project_market_id: | ||
raise UserError( | ||
_('The analytic account %s ' | ||
'does not have a Project Market') % analytic.name | ||
) | ||
values.update({ | ||
'project_zone_id': analytic.project_zone_id.id, | ||
'project_process_id': analytic.project_process_id.id, | ||
'project_market_id': analytic.project_market_id.id, | ||
'sales_condition': base64.encodestring( | ||
'Intercompany sales conditions.' | ||
), | ||
'sales_condition_filename': 'intercompany.txt', | ||
'engineering_validation_id': 1, | ||
'process_validation_id': 1, | ||
'system_validation_id': 1, | ||
'force_project_name': analytic.name, | ||
} | ||
) | ||
return values |
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
17 changes: 17 additions & 0 deletions
17
odoo/local-src/specific_sale/models/account_analytic_account.py
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,17 @@ | ||
# -*- coding: utf-8 -*- | ||
# Author: Alexandre Fayolle | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class AccountAnalyticAccount(models.Model): | ||
_inherit = 'account.analytic.account' | ||
|
||
project_zone_id = fields.Many2one(comodel_name='project.zone', | ||
string='Project Zone') | ||
project_process_id = fields.Many2one(comodel_name='project.process', | ||
string='Project Process') | ||
project_market_id = fields.Many2one(comodel_name='project.market', | ||
string='Project Market') |
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
import anthem | ||
|
||
|
||
@anthem.log | ||
def set_intercompany_rules(ctx): | ||
warehouse = ctx.env['stock.warehouse'] | ||
holding = ctx.env.ref('__setup__.roctool_holding') | ||
for company in ctx.env['res.company'].search([('id', '!=', holding.id)]): | ||
warehouse_id = warehouse.search([('company_id', '=', company.id)])[0] | ||
vals = { | ||
'so_from_po': (company.name == 'RocTool SA'), | ||
'po_from_so': False, | ||
'warehouse_id': warehouse_id.id, | ||
'ref': 'r%s' % company.country_id.code.lower(), | ||
'customer': 1, | ||
'supplier': (company.name == 'RocTool SA'), | ||
} | ||
company.write(vals) | ||
|
||
|
||
@anthem.log | ||
def main(ctx): | ||
""" Main: creating intercompany rules """ | ||
set_intercompany_rules(ctx) |