From 2d3a5a44e4f15dec6c64fb5d6b412f33e4840533 Mon Sep 17 00:00:00 2001 From: Sudhir Arya Date: Wed, 23 Dec 2015 19:24:56 +0530 Subject: [PATCH 001/130] [ADD] Added Account Operating Unit module for v9. --- account_operating_unit/README.rst | 78 +++++++++++ account_operating_unit/__init__.py | 6 + account_operating_unit/__openerp__.py | 30 +++++ .../demo/account_minimal.xml | 26 ++++ account_operating_unit/models/__init__.py | 8 ++ .../models/account_account.py | 15 +++ account_operating_unit/models/account_move.py | 126 ++++++++++++++++++ account_operating_unit/models/company.py | 13 ++ account_operating_unit/models/invoice.py | 52 ++++++++ .../security/account_security.xml | 39 ++++++ .../static/description/icon.png | Bin 0 -> 9455 bytes account_operating_unit/tests/__init__.py | 8 ++ .../tests/test_account_operating_unit.py | 71 ++++++++++ .../tests/test_cross_ou_journal_entry.py | 92 +++++++++++++ .../tests/test_invoice_operating_unit.py | 56 ++++++++ .../tests/test_operating_unit_security.py | 18 +++ .../views/account_account_view.xml | 17 +++ .../views/account_move_view.xml | 76 +++++++++++ account_operating_unit/views/company_view.xml | 17 +++ account_operating_unit/views/invoice_view.xml | 55 ++++++++ account_operating_unit/wizard/__init__.py | 6 + .../wizard/account_financial_report.py | 31 +++++ .../wizard/account_financial_report_view.xml | 19 +++ .../wizard/account_report_common.py | 22 +++ .../wizard/account_report_common_view.xml | 21 +++ 25 files changed, 902 insertions(+) create mode 100644 account_operating_unit/README.rst create mode 100644 account_operating_unit/__init__.py create mode 100644 account_operating_unit/__openerp__.py create mode 100644 account_operating_unit/demo/account_minimal.xml create mode 100644 account_operating_unit/models/__init__.py create mode 100644 account_operating_unit/models/account_account.py create mode 100644 account_operating_unit/models/account_move.py create mode 100644 account_operating_unit/models/company.py create mode 100644 account_operating_unit/models/invoice.py create mode 100644 account_operating_unit/security/account_security.xml create mode 100644 account_operating_unit/static/description/icon.png create mode 100644 account_operating_unit/tests/__init__.py create mode 100644 account_operating_unit/tests/test_account_operating_unit.py create mode 100644 account_operating_unit/tests/test_cross_ou_journal_entry.py create mode 100644 account_operating_unit/tests/test_invoice_operating_unit.py create mode 100644 account_operating_unit/tests/test_operating_unit_security.py create mode 100644 account_operating_unit/views/account_account_view.xml create mode 100644 account_operating_unit/views/account_move_view.xml create mode 100644 account_operating_unit/views/company_view.xml create mode 100644 account_operating_unit/views/invoice_view.xml create mode 100644 account_operating_unit/wizard/__init__.py create mode 100644 account_operating_unit/wizard/account_financial_report.py create mode 100644 account_operating_unit/wizard/account_financial_report_view.xml create mode 100644 account_operating_unit/wizard/account_report_common.py create mode 100644 account_operating_unit/wizard/account_report_common_view.xml diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst new file mode 100644 index 0000000000..5fd576213c --- /dev/null +++ b/account_operating_unit/README.rst @@ -0,0 +1,78 @@ +.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg + :target: https://www.gnu.org/licenses/lgpl.html + :alt: License: LGPL-3 + +=============================== +Accounting with Operating Units +=============================== + +This module introduces the following features: +- Adds the Operating Unit in the account move line. +- Define an Inter-operating unit clearing account at company level. +- When users create a journal entry with lines in different operating units, +at the time of posting the journal entry it automatically creates the corresponding +lines in the Inter-operating unit clearing account, making each OU self-balancing. +- Introduces checks that prevent users from entering cross-operating unit +journal entries using different accounts. + +Installation +============ + +No external library is used. + +Configuration +============= + +To configure this module, you need to: + +* Create an account for "Inter-OU Clearing" of type Regular. +* Go to *Settings / Companies / Companies* and configure "Inter-OU Clearing" account in "Inter-operating unit clearing account" field. +* Assign Operating Unit in Accounts. + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/213/9.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Eficent +* Serpent Consulting Services Pvt. Ltd. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file diff --git a/account_operating_unit/__init__.py b/account_operating_unit/__init__.py new file mode 100644 index 0000000000..5c7a28df15 --- /dev/null +++ b/account_operating_unit/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import models +from . import wizard diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py new file mode 100644 index 0000000000..4e2d8fd6e8 --- /dev/null +++ b/account_operating_unit/__openerp__.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": 'Accounting with Operating Units', + "summary": "An operating unit (OU) is an organizational entity part of a\ + company", + "version": "9.0.1.0.0", + "author": "Eficent, Serpent Consulting Services Pvt. Ltd.," + "Odoo Community Association (OCA)", + "website": "http://www.eficent.com", + "category": "Generic/Sales & Purchases", + "depends": ['account', 'operating_unit'], + "license": "LGPL-3", + "data": [ + "security/account_security.xml", + "views/account_move_view.xml", + "views/account_account_view.xml", + "views/company_view.xml", + "views/invoice_view.xml", + "wizard/account_report_common_view.xml", + "wizard/account_financial_report_view.xml", + ], + "demo": [ + "demo/account_minimal.xml", + ], + "installable": True, +} diff --git a/account_operating_unit/demo/account_minimal.xml b/account_operating_unit/demo/account_minimal.xml new file mode 100644 index 0000000000..a9eed83e11 --- /dev/null +++ b/account_operating_unit/demo/account_minimal.xml @@ -0,0 +1,26 @@ + + + + + + X1115 + Inter-OU Clearing - (test) + + + + + + + + diff --git a/account_operating_unit/models/__init__.py b/account_operating_unit/models/__init__.py new file mode 100644 index 0000000000..12ea5ff604 --- /dev/null +++ b/account_operating_unit/models/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import company +from . import account_account +from . import account_move +from . import invoice diff --git a/account_operating_unit/models/account_account.py b/account_operating_unit/models/account_account.py new file mode 100644 index 0000000000..116eb6059c --- /dev/null +++ b/account_operating_unit/models/account_account.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp import fields, models + + +class AccountAccount(models.Model): + _inherit = "account.account" + + operating_unit_id = fields.Many2one('operating.unit', + 'Default Operating Unit', + default=lambda self: + self.env['res.users']. + operating_unit_default_get(self._uid)) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py new file mode 100644 index 0000000000..3be84c658c --- /dev/null +++ b/account_operating_unit/models/account_move.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp.tools.translate import _ +from openerp import api, fields, models +from openerp.exceptions import UserError + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + @api.model + def _query_get(self, domain=None): + if self._context.get('operating_unit_ids', False): + domain.append(('operating_unit_id', 'in', + self._context.get('operating_unit_ids'))) + return super(AccountMoveLine, self)._query_get(domain) + + operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit', + default=lambda self: + self.env['res.users']. + operating_unit_default_get(self._uid)) + ou_cleared_line_id = fields.Many2one('account.move.line', + 'Inter-OU Cleared move line') + + @api.one + @api.constrains('operating_unit_id', 'company_id') + def _check_company_operating_unit(self): + if self.company_id and self.operating_unit_id and \ + self.company_id != self.operating_unit_id.company_id: + raise UserError(_('Configuration error!\nThe Company in the\ + Move Line and in the Operating Unit must be the same.')) + + +class AccountMove(models.Model): + _inherit = "account.move" + + @api.multi + def post(self): + ml_obj = self.env['account.move.line'] + for move in self: + # If all move lines point to the same operating unit, there's no + # need to create a balancing move line + ou_list_ids = ml_obj.read_group([('move_id', '=', move.id)], + ['operating_unit_id'], + ['operating_unit_id']) + if len(ou_list_ids) <= 1: + continue + lines = [] + for line in move.line_ids: + cleared = False + operating_unit = line.operating_unit_id + if operating_unit: + cl_acc = line.company_id.inter_ou_clearing_account_id + if not cl_acc: + raise UserError(_('Configuration error!\n\ + You need to define an inter-operating unit clearing\ + account in the company settings.')) + if line.account_id == cl_acc: + continue + # Check if this line has already been cleared + for l in move.line_ids: + if line == l.ou_cleared_line_id: + cleared = True + if cleared: + continue + + # Create a balancing move line in the operating unit + # clearing account + line_vals = { + 'name': line.name, + 'partner_id': line.partner_id and + line.partner_id.id or False, + 'account_id': cl_acc.id, + 'move_id': line.move_id.id, + 'journal_id': line.journal_id.id, + 'date': line.date, + 'debit': line.credit, + 'credit': line.debit, + 'currency_id': line.currency_id.id, + 'amount_currency': line.amount_currency, + 'operating_unit_id': operating_unit.id, + 'analytic_account_id': line.analytic_account_id.id, + 'ou_cleared_line_id': line.id, + } + lines.append((0, 0, line_vals)) + move.write({'line_ids': lines}) + return super(AccountMove, self).post() + + @api.one + @api.constrains('line_ids') + def _check_same_ou_dr_cr(self): + dr = {} + cr = {} + ou_ids = [] + for line in self.line_ids: + operating_unit_id = line.operating_unit_id and \ + line.operating_unit_id.id + if operating_unit_id: + cl_acc = line.company_id.inter_ou_clearing_account_id + if not cl_acc: + raise UserError(_('Configuration error!\n\ + You need to define an inter-operating\ + unit clearing account in the company settings.')) + ou_ids.append(operating_unit_id) + if not cl_acc: + if operating_unit_id in dr: + dr[operating_unit_id] += line.debit + else: + dr[operating_unit_id] = line.debit + + if operating_unit_id in cr: + cr[operating_unit_id] += line.credit + else: + cr[operating_unit_id] = line.credit + for ou_id in ou_ids: + if ( + ou_id in dr and + ou_id in cr and + dr[ou_id] > 0 and + cr[ou_id] > 0 + ): + raise UserError(_('Configuration error!\nThe same\ + operating unit cannot exist in the debit and credit\ + for the same account.')) diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py new file mode 100644 index 0000000000..ffd56d47a5 --- /dev/null +++ b/account_operating_unit/models/company.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp import fields, models + + +class ResCompany(models.Model): + _inherit = 'res.company' + + inter_ou_clearing_account_id = fields.Many2one('account.account', + 'Inter-operating unit\ + clearing account') diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py new file mode 100644 index 0000000000..37dd79f786 --- /dev/null +++ b/account_operating_unit/models/invoice.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp import api, fields, models + + +class AccountInvoice(models.Model): + _inherit = "account.invoice" + + operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit', + default=lambda self: + self.env['res.users']. + operating_unit_default_get(self._uid)) + + @api.multi + def finalize_invoice_move_lines(self, move_lines): + move_lines = super(AccountInvoice, + self).finalize_invoice_move_lines(move_lines) + new_move_lines = [] + for line_tuple in move_lines: + if self.operating_unit_id: + line_tuple[2]['operating_unit_id'] = \ + self.operating_unit_id.id + new_move_lines.append(line_tuple) + return new_move_lines + + @api.multi + def _check_company_operating_unit(self): + for pr in self.browse(): + if ( + pr.company_id and + pr.operating_unit_id and + pr.company_id != pr.operating_unit_id.company_id + ): + return False + return True + + _constraints = [ + (_check_company_operating_unit, + 'The Company in the Invoice and in the Operating ' + 'Unit must be the same.', ['operating_unit_id', + 'company_id'])] + + +class AccountInvoiceLine(models.Model): + _inherit = 'account.invoice.line' + + operating_unit_id = fields.Many2one('operating.unit', + related='invoice_id.operating_unit_id', + string='Operating Unit', store=True, + readonly=True) diff --git a/account_operating_unit/security/account_security.xml b/account_operating_unit/security/account_security.xml new file mode 100644 index 0000000000..24f9b7c9dc --- /dev/null +++ b/account_operating_unit/security/account_security.xml @@ -0,0 +1,39 @@ + + + + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Invoices from allowed operating units + + + + + + + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Invoice lines from allowed operating units + + + + + + + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Move Lines from allowed operating units + + + + + + + + + diff --git a/account_operating_unit/static/description/icon.png b/account_operating_unit/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9 zeKEe+b0{#KWGp$F+tga)0RtI)nhMa-K@JS}2krK~n8vJ=Ngm?R!9G<~RyuU0d?nz# z-5EK$o(!F?hmX*2Yt6+coY`6jGbb7tF#6nHA zuKk=GGJ;ZwON1iAfG$E#Y7MnZVmrY|j0eVI(DN_MNFJmyZ|;w4tf@=CCDZ#5N_0K= z$;R~bbk?}TpfDjfB&aiQ$VA}s?P}xPERJG{kxk5~R`iRS(SK5d+Xs9swCozZISbnS zk!)I0>t=A<-^z(cmSFz3=jZ23u13X><0b)P)^1T_))Kr`e!-pb#q&J*Q`p+B6la%C zuVl&0duN<;uOsB3%T9Fp8t{ED108<+W(nOZd?gDnfNBC3>M8WE61$So|P zVvqH0SNtDTcsUdzaMDpT=Ty0pDHHNL@Z0w$Y`XO z2M-_r1S+GaH%pz#Uy0*w$Vdl=X=rQXEzO}d6J^R6zjM1u&c9vYLvLp?W7w(?np9x1 zE_0JSAJCPB%i7p*Wvg)pn5T`8k3-uR?*NT|J`eS#_#54p>!p(mLDvmc-3o0mX*mp_ zN*AeS<>#^-{S%W<*mz^!X$w_2dHWpcJ6^j64qFBft-o}o_Vx80o0>}Du;>kLts;$8 zC`7q$QI(dKYG`Wa8#wl@V4jVWBRGQ@1dr-hstpQL)Tl+aqVpGpbSfN>5i&QMXfiZ> zaA?T1VGe?rpQ@;+pkrVdd{klI&jVS@I5_iz!=UMpTsa~mBga?1r}aRBm1WS;TT*s0f0lY=JBl66Upy)-k4J}lh=P^8(SXk~0xW=T9v*B|gzIhN z>qsO7dFd~mgxAy4V?&)=5ieYq?zi?ZEoj)&2o)RLy=@hbCRcfT5jigwtQGE{L*8<@Yd{zg;CsL5mvzfDY}P-wos_6PfprFVaeqNE%h zKZhLtcQld;ZD+>=nqN~>GvROfueSzJD&BE*}XfU|H&(FssBqY=hPCt`d zH?@s2>I(|;fcW&YM6#V#!kUIP8$Nkdh0A(bEVj``-AAyYgwY~jB zT|I7Bf@%;7aL7Wf4dZ%VqF$eiaC38OV6oy3Z#TER2G+fOCd9Iaoy6aLYbPTN{XRPz z;U!V|vBf%H!}52L2gH_+j;`bTcQRXB+y9onc^wLm5wi3-Be}U>k_u>2Eg$=k!(l@I zcCg+flakT2Nej3i0yn+g+}%NYb?ta;R?(g5SnwsQ49U8Wng8d|{B+lyRcEDvR3+`O{zfmrmvFrL6acVP%yG98X zo&+VBg@px@i)%o?dG(`T;n*$S5*rnyiR#=wW}}GsAcfyQpE|>a{=$Hjg=-*_K;UtD z#z-)AXwSRY?OPefw^iI+ z)AXz#PfEjlwTes|_{sB?4(O@fg0AJ^g8gP}ex9Ucf*@_^J(s_5jJV}c)s$`Myn|Kd z$6>}#q^n{4vN@+Os$m7KV+`}c%4)4pv@06af4-x5#wj!KKb%caK{A&Y#Rfs z-po?Dcb1({W=6FKIUirH&(yg=*6aLCekcKwyfK^JN5{wcA3nhO(o}SK#!CINhI`-I z1)6&n7O&ZmyFMuNwvEic#IiOAwNkR=u5it{B9n2sAJV5pNhar=j5`*N!Na;c7g!l$ z3aYBqUkqqTJ=Re-;)s!EOeij=7SQZ3Hq}ZRds%IM*PtM$wV z@;rlc*NRK7i3y5BETSKuumEN`Xu_8GP1Ri=OKQ$@I^ko8>H6)4rjiG5{VBM>B|%`&&s^)jS|-_95&yc=GqjNo{zFkw%%HHhS~e=s zD#sfS+-?*t|J!+ozP6KvtOl!R)@@-z24}`9{QaVLD^9VCSR2b`b!KC#o;Ki<+wXB6 zx3&O0LOWcg4&rv4QG0)4yb}7BFSEg~=IR5#ZRj8kg}dS7_V&^%#Do==#`u zpy6{ox?jWuR(;pg+f@mT>#HGWHAJRRDDDv~@(IDw&R>9643kK#HN`!1vBJHnC+RM&yIh8{gG2q zA%e*U3|N0XSRa~oX-3EAneep)@{h2vvd3Xvy$7og(sayr@95+e6~Xvi1tUqnIxoIH zVWo*OwYElb#uyW{Imam6f2rGbjR!Y3`#gPqkv57dB6K^wRGxc9B(t|aYDGS=m$&S!NmCtrMMaUg(c zc2qC=2Z`EEFMW-me5B)24AqF*bV5Dr-M5ig(l-WPS%CgaPzs6p_gnCIvTJ=Y<6!gT zVt@AfYCzjjsMEGi=rDQHo0yc;HqoRNnNFeWZgcm?f;cp(6CNylj36DoL(?TS7eU#+ z7&mfr#y))+CJOXQKUMZ7QIdS9@#-}7y2K1{8)cCt0~-X0O!O?Qx#E4Og+;A2SjalQ zs7r?qn0H044=sDN$SRG$arw~n=+T_DNdSrarmu)V6@|?1-ZB#hRn`uilTGPJ@fqEy zGt(f0B+^JDP&f=r{#Y_wi#AVDf-y!RIXU^0jXsFpf>=Ji*TeqSY!H~AMbJdCGLhC) zn7Rx+sXw6uYj;WRYrLd^5IZq@6JI1C^YkgnedZEYy<&4(z%Q$5yv#Boo{AH8n$a zhb4Y3PWdr269&?V%uI$xMcUrMzl=;w<_nm*qr=c3Rl@i5wWB;e-`t7D&c-mcQl7x! zZWB`UGcw=Y2=}~wzrfLx=uet<;m3~=8I~ZRuzvMQUQdr+yTV|ATf1Uuomr__nDf=X zZ3WYJtHp_ri(}SQAPjv+Y+0=fH4krOP@S&=zZ-t1jW1o@}z;xk8 z(Nz1co&El^HK^NrhVHa-_;&88vTU>_J33=%{if;BEY*J#1n59=07jrGQ#IP>@u#3A z;!q+E1Rj3ZJ+!4bq9F8PXJ@yMgZL;>&gYA0%_Kbi8?S=XGM~dnQZQ!yBSgcZhY96H zrWnU;k)qy`rX&&xlDyA%(a1Hhi5CWkmg(`Gb%m(HKi-7Z!LKGRP_B8@`7&hdDy5n= z`OIxqxiVfX@OX1p(mQu>0Ai*v_cTMiw4qRt3~NBvr9oBy0)r>w3p~V0SCm=An6@3n)>@z!|o-$HvDK z|3D2ZMJkLE5loMKl6R^ez@Zz%S$&mbeoqH5`Bb){Ei21q&VP)hWS2tjShfFtGE+$z zzCR$P#uktu+#!w)cX!lWN1XU%K-r=s{|j?)Akf@q#3b#{6cZCuJ~gCxuMXRmI$nGtnH+-h z+GEi!*X=AP<|fG`1>MBdTb?28JYc=fGvAi2I<$B(rs$;eoJCyR6_bc~p!XR@O-+sD z=eH`-ye})I5ic1eL~TDmtfJ|8`0VJ*Yr=hNCd)G1p2MMz4C3^Mj?7;!w|Ly%JqmuW zlIEW^Ft%z?*|fpXda>Jr^1noFZEwFgVV%|*XhH@acv8rdGxeEX{M$(vG{Zw+x(ei@ zmfXb22}8-?Fi`vo-YVrTH*C?a8%M=Hv9MqVH7H^J$KsD?>!SFZ;ZsvnHr_gn=7acz z#W?0eCdVhVMWN12VV^$>WlQ?f;P^{(&pYTops|btm6aj>_Uz+hqpGwB)vWp0Cf5y< zft8-je~nn?W11plq}N)4A{l8I7$!ks_x$PXW-2XaRFswX_BnF{R#6YIwMhAgd5F9X zGmwdadS6(a^fjHtXg8=l?Rc0Sm%hk6E9!5cLVloEy4eh(=FwgP`)~I^5~pBEWo+F6 zSf2ncyMurJN91#cJTy_u8Y}@%!bq1RkGC~-bV@SXRd4F{R-*V`bS+6;W5vZ(&+I<9$;-V|eNfLa5n-6% z2(}&uGRF;p92eS*sE*oR$@pexaqr*meB)VhmIg@h{uzkk$9~qh#cHhw#>O%)b@+(| z^IQgqzuj~Sk(J;swEM-3TrJAPCq9k^^^`q{IItKBRXYe}e0Tdr=Huf7da3$l4PdpwWDop%^}n;dD#K4s#DYA8SHZ z&1!riV4W4R7R#C))JH1~axJ)RYnM$$lIR%6fIVA@zV{XVyx}C+a-Dt8Y9M)^KU0+H zR4IUb2CJ{Hg>CuaXtD50jB(_Tcx=Z$^WYu2u5kubqmwp%drJ6 z?Fo40g!Qd<-l=TQxqHEOuPX0;^z7iX?Ke^a%XT<13TA^5`4Xcw6D@Ur&VT&CUe0d} z1GjOVF1^L@>O)l@?bD~$wzgf(nxX1OGD8fEV?TdJcZc2KoUe|oP1#=$$7ee|xbY)A zDZq+cuTpc(fFdj^=!;{k03C69lMQ(|>uhRfRu%+!k&YOi-3|1QKB z z?n?eq1XP>p-IM$Z^C;2L3itnbJZAip*Zo0aw2bs8@(s^~*8T9go!%dHcAz2lM;`yp zD=7&xjFV$S&5uDaiScyD?B-i1ze`+CoRtz`Wn+Zl&#s4&}MO{@N!ufrzjG$B79)Y2d3tBk&)TxUTw@QS0TEL_?njX|@vq?Uz(nBFK5Pq7*xj#u*R&i|?7+6# z+|r_n#SW&LXhtheZdah{ZVoqwyT{D>MC3nkFF#N)xLi{p7J1jXlmVeb;cP5?e(=f# zuT7fvjSbjS781v?7{)-X3*?>tq?)Yd)~|1{BDS(pqC zC}~H#WXlkUW*H5CDOo<)#x7%RY)A;ShGhI5s*#cRDA8YgqG(HeKDx+#(ZQ?386dv! zlXCO)w91~Vw4AmOcATuV653fa9R$fyK8ul%rG z-wfS zihugoZyr38Im?Zuh6@RcF~t1anQu7>#lPpb#}4cOA!EM11`%f*07RqOVkmX{p~KJ9 z^zP;K#|)$`^Rb{rnHGH{~>1(fawV0*Z#)}M`m8-?ZJV<+e}s9wE# z)l&az?w^5{)`S(%MRzxdNqrs1n*-=jS^_jqE*5XDrA0+VE`5^*p3CuM<&dZEeCjoz zR;uu_H9ZPZV|fQq`Cyw4nscrVwi!fE6ciMmX$!_hN7uF;jjKG)d2@aC4ropY)8etW=xJvni)8eHi`H$%#zn^WJ5NLc-rqk|u&&4Z6fD_m&JfSI1Bvb?b<*n&sfl0^t z=HnmRl`XrFvMKB%9}>PaA`m-fK6a0(8=qPkWS5bb4=v?XcWi&hRY?O5HdulRi4?fN zlsJ*N-0Qw+Yic@s0(2uy%F@ib;GjXt01Fmx5XbRo6+n|pP(&nodMoap^z{~q ziEeaUT@Mxe3vJSfI6?uLND(CNr=#^W<1b}jzW58bIfyWTDle$mmS(|x-0|2UlX+9k zQ^EX7Nw}?EzVoBfT(-LT|=9N@^hcn-_p&sqG z&*oVs2JSU+N4ZD`FhCAWaS;>|wH2G*Id|?pa#@>tyxX`+4HyIArWDvVrX)2WAOQff z0qyHu&-S@i^MS-+j--!pr4fPBj~_8({~e1bfcl0wI1kaoN>mJL6KUPQm5N7lB(ui1 zE-o%kq)&djzWJ}ob<-GfDlkB;F31j-VHKvQUGQ3sp`CwyGJk_i!y^sD0fqC@$9|jO zOqN!r!8-p==F@ZVP=U$qSpY(gQ0)59P1&t@y?5rvg<}E+GB}26NYPp4f2YFQrQtot5mn3wu_qprZ=>Ig-$ zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/account_operating_unit/tests/__init__.py b/account_operating_unit/tests/__init__.py new file mode 100644 index 0000000000..233eca4b1b --- /dev/null +++ b/account_operating_unit/tests/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import test_account_operating_unit +from . import test_invoice_operating_unit +from . import test_cross_ou_journal_entry +from . import test_operating_unit_security diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py new file mode 100644 index 0000000000..ec54e4f86b --- /dev/null +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp.addons.account.tests import account_test_classes + + +class TestAccountOperatingUnit(account_test_classes.AccountingTestCase): + + def setUp(self): + super(TestAccountOperatingUnit, self).setUp() + self.res_users_model = self.env['res.users'] + self.aml_model = self.env['account.move.line'] + self.account_model = self.env['account.account'] + # company + self.company = self.env.ref('base.main_company') + self.grp_acc_user = self.env.ref('account.group_account_invoice') + # Main Operating Unit + self.ou1 = self.env.ref('operating_unit.main_operating_unit') + # B2B Operating Unit + self.b2b = self.env.ref('operating_unit.b2b_operating_unit') + # B2C Operating Unit + self.b2c = self.env.ref('operating_unit.b2c_operating_unit') + # Partner + self.partner1 = self.env.ref('base.res_partner_1') + # Products + self.product1 = self.env.ref('product.product_product_7') + self.product2 = self.env.ref('product.product_product_9') + self.product3 = self.env.ref('product.product_product_11') + # Create user1 + self.user_id =\ + self.res_users_model.with_context({'no_reset_password': True}).\ + create({ + 'name': 'Test Account User', + 'login': 'user_1', + 'password': 'demo', + 'email': 'example@yourcompany.com', + 'company_id': self.company.id, + 'company_ids': [(4, self.company.id)], + 'operating_unit_ids': [(4, self.b2b.id), (4, self.b2c.id)], + 'groups_id': [(6, 0, [self.grp_acc_user.id])] + }) + # Create cash - test account + user_type = self.env.ref('account.data_account_type_liquidity') + self.cash_account_id = self.account_model.create({ + 'name': 'Cash - Test', + 'code': 'test_cash', + 'user_type_id': user_type.id, + 'company_id': self.company.id + }) + # Create Inter-OU Clearing - test account + user_type = self.env.ref('account.data_account_type_equity') + self.inter_ou_account_id = self.account_model.create({ + 'name': 'Inter-OU Clearing', + 'code': 'test_inter_ou', + 'user_type_id': user_type.id, + 'company_id': self.company.id + }) + # Create user2 + self.user2_id =\ + self.res_users_model.with_context({'no_reset_password': True}).\ + create({ + 'name': 'Test Account User', + 'login': 'user_2', + 'password': 'demo', + 'email': 'example@yourcompany.com', + 'company_id': self.company.id, + 'company_ids': [(4, self.company.id)], + 'operating_unit_ids': [(4, self.b2c.id)], + 'groups_id': [(6, 0, [self.grp_acc_user.id])] + }) diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py new file mode 100644 index 0000000000..dba1400fed --- /dev/null +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp.addons.account_operating_unit.tests import\ + test_account_operating_unit as test_ou + + +class TestCrossOuJournalEntry(test_ou.TestAccountOperatingUnit): + + def test_cross_ou_journal_entry(self): + """Test balance of cross OU journal entries. + Test that when I create a manual journal entry with multiple + operating units, new cross-operating unit entries are created + automatically whent the journal entry is posted, ensuring that each + OU is self-balanced.""" + # Create Journal Entries and check the balance of the account + # based on different operating units. + self.company.write({ + 'inter_ou_clearing_account_id': self.inter_ou_account_id.id, + }) + self.acc_move_model = self.env['account.move'] + self.journal_model = self.env['account.journal'] + # Create Journal Entries + journal_ids = self.journal_model.search([('code', '=', 'MISC')], + limit=1) + # get default values of account move + move_vals = self.acc_move_model.default_get([]) + lines = [ + (0, 0, { + 'name': 'Test', + 'account_id': self.cash_account_id.id, + 'debit': 0, + 'credit': 100, + 'operating_unit_id': self.b2b.id, + }), + (0, 0, { + 'name': 'Test', + 'account_id': self.cash_account_id.id, + 'debit': 100, + 'credit': 0, + 'operating_unit_id': self.b2c.id, + }) + ] + move_vals.update({ + 'journal_id': journal_ids and journal_ids.id, + 'line_ids': lines, + }) + move = self.acc_move_model.sudo(self.user_id.id).create(move_vals) + # Post journal entries + move.post() + # Check the balance of the account + self._check_balance(self.cash_account_id.id, acc_type='cash') + clearing_account_id = self.company.inter_ou_clearing_account_id.id + self._check_balance(clearing_account_id, acc_type='clearing') + + def _check_balance(self, account_id, acc_type='clearing'): + # Check balance for all operating units + domain = [('account_id', '=', account_id)] + balance = self._get_balance(domain) + self.assertEqual(balance, 0.0, 'Balance is 0 for all Operating Units.') + # Check balance for operating B2B units + domain = [('account_id', '=', account_id), + ('operating_unit_id', '=', self.b2b.id)] + balance = self._get_balance(domain) + if acc_type == 'cash': + self.assertEqual(balance, -100, + 'Balance is -100 for Operating Unit B2B.') + else: + self.assertEqual(balance, 100, + 'Balance is 100 for Operating Unit B2B.') + # Check balance for operating B2C units + domain = [('account_id', '=', account_id), + ('operating_unit_id', '=', self.b2c.id)] + balance = self._get_balance(domain) + if acc_type == 'cash': + self.assertEqual(balance, 100.0, + 'Balance is 100 for Operating Unit B2C.') + else: + self.assertEqual(balance, -100.0, + 'Balance is -100 for Operating Unit B2C.') + + def _get_balance(self, domain): + """ + Call read_group method and return the balance of particular account. + """ + aml_rec =\ + self.aml_model.sudo(self.user_id.id).read_group(domain, + ['debit', 'credit', + 'account_id'], + ['account_id'])[0] + return aml_rec.get('debit', 0) - aml_rec.get('credit', 0) diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py new file mode 100644 index 0000000000..114d5d7eee --- /dev/null +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp.addons.account_operating_unit.tests import\ + test_account_operating_unit as test_ou + + +class TestInvoiceOperatingUnit(test_ou.TestAccountOperatingUnit): + + def test_create_invoice_validate(self): + """Create & Validate the invoice. + Test that when an invoice is created, the operating unit is + passed to the accounting journal items. + """ + line_products = [(self.product1, 1000), + (self.product2, 500), + (self.product3, 800)] + self.invoice_model = self.env['account.invoice'] + self.journal_model = self.env['account.journal'] + self.product_model = self.env['product.product'] + self.inv_line_model = self.env['account.invoice.line'] + # Prepare invoice lines + lines = [] + acc_type = self.env.ref('account.data_account_type_expenses') + for product, qty in line_products: + line_values = { + 'name': product.name, + 'product_id': product.id, + 'quantity': qty, + 'price_unit': 50, + 'account_id': self.env['account.account']. + search([('user_type_id', '=', acc_type.id)], limit=1).id, + } + lines.append((0, 0, line_values)) + inv_vals = { + 'partner_id': self.partner1.id, + 'account_id': self.partner1.property_account_payable_id.id, + 'operating_unit_id': self.b2b.id, + 'name': "Test Supplier Invoice", + 'reference_type': "none", + 'type': 'in_invoice', + 'invoice_line_ids': lines, + } + # Create invoice + self.invoice =\ + self.invoice_model.sudo(self.user_id.id).create(inv_vals) + # Validate the invoice + self.invoice.signal_workflow('invoice_open') + # Check Operating Units in journal entries + all_op_units = all(move_line.operating_unit_id.id == self.b2b.id for + move_line in self.invoice.move_id.line_ids) + # Assert if journal entries of the invoice + # have different operating units + self.assertNotEqual(all_op_units, False, 'Journal Entries have\ + different Operating Units.') diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py new file mode 100644 index 0000000000..a3810bd9d4 --- /dev/null +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp.addons.account_operating_unit.tests import\ + test_account_operating_unit as test_ou + + +class TestOuSecurity(test_ou.TestAccountOperatingUnit): + + def test_security(self): + """Test Security of Account Operating Unit""" + # User 2 is only assigned to Operating Unit B2C, and cannot list + # Journal Entries from Operating Unit B2B. + move_ids = self.aml_model.sudo(self.user2_id.id).\ + search([('operating_unit_id', '=', self.b2b.id)]) + self.assertEqual(move_ids, [], 'user_2 should not have access to ' + 'OU %s' % self.b2b.name) diff --git a/account_operating_unit/views/account_account_view.xml b/account_operating_unit/views/account_account_view.xml new file mode 100644 index 0000000000..048404dc6a --- /dev/null +++ b/account_operating_unit/views/account_account_view.xml @@ -0,0 +1,17 @@ + + + + + + account.account.form + account.account + + + + + + + + + + diff --git a/account_operating_unit/views/account_move_view.xml b/account_operating_unit/views/account_move_view.xml new file mode 100644 index 0000000000..94e337003c --- /dev/null +++ b/account_operating_unit/views/account_move_view.xml @@ -0,0 +1,76 @@ + + + + + + account.move.line.form + account.move.line + + + + + + + + + + + account.move.line.form2 + account.move.line + + + + + + + + + + + account.move.line.tree + account.move.line + + + + + + + + + + + Journal Items + account.move.line + + + + + + + + + + + + account.move.form + account.move + + + + + + + + + + + + diff --git a/account_operating_unit/views/company_view.xml b/account_operating_unit/views/company_view.xml new file mode 100644 index 0000000000..4c1f18a654 --- /dev/null +++ b/account_operating_unit/views/company_view.xml @@ -0,0 +1,17 @@ + + + + + + res.company.form + res.company + + + + + + + + + + diff --git a/account_operating_unit/views/invoice_view.xml b/account_operating_unit/views/invoice_view.xml new file mode 100644 index 0000000000..a314803b73 --- /dev/null +++ b/account_operating_unit/views/invoice_view.xml @@ -0,0 +1,55 @@ + + + + + + account.invoice.tree + account.invoice + + + + + + + + + + account.invoice.select + account.invoice + + + + + + + + + + + + + account.invoice.supplier.form + account.invoice + + + + + + + + + + account.invoice.form + account.invoice + + + + + + + + + + diff --git a/account_operating_unit/wizard/__init__.py b/account_operating_unit/wizard/__init__.py new file mode 100644 index 0000000000..61d0577d10 --- /dev/null +++ b/account_operating_unit/wizard/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import account_report_common +from . import account_financial_report diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py new file mode 100644 index 0000000000..d8703956cd --- /dev/null +++ b/account_operating_unit/wizard/account_financial_report.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp import fields, models + + +class AccountingReport(models.TransientModel): + + _inherit = "accounting.report" + + operating_unit_ids = fields.Many2many('operating.unit', + string='Operating Units', + required=False) + + def _build_contexts(self, data): + result = super(AccountingReport, self)._build_contexts(data) + data2 = {} + data2['form'] = self.read(['operating_unit_ids'])[0] + result['operating_unit_ids'] = 'operating_unit_ids' in data2['form']\ + and data2['form']['operating_unit_ids']\ + or False + return result + + def _build_comparison_context(self, data): + result = super(AccountingReport, self)._build_comparison_context(data) + data['form'] = self.read(['operating_unit_ids'])[0] + result['operating_unit_ids'] = 'operating_unit_ids' in data['form'] \ + and data['form']['operating_unit_ids'] \ + or False + return result diff --git a/account_operating_unit/wizard/account_financial_report_view.xml b/account_operating_unit/wizard/account_financial_report_view.xml new file mode 100644 index 0000000000..f0377355e7 --- /dev/null +++ b/account_operating_unit/wizard/account_financial_report_view.xml @@ -0,0 +1,19 @@ + + + + + + Accounting Report + accounting.report + + + + + + + + + + + + diff --git a/account_operating_unit/wizard/account_report_common.py b/account_operating_unit/wizard/account_report_common.py new file mode 100644 index 0000000000..3f0449cb3c --- /dev/null +++ b/account_operating_unit/wizard/account_report_common.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp import fields, models + + +class AccountCommonReport(models.TransientModel): + _inherit = "account.common.report" + + operating_unit_ids = fields.Many2many('operating.unit', + string='Operating Units', + required=False) + + def _build_contexts(self, data): + result = super(AccountCommonReport, self)._build_contexts(data) + data2 = {} + data2['form'] = self.read(['operating_unit_ids'])[0] + result['operating_unit_ids'] = \ + 'operating_unit_ids' in data2['form'] \ + and data2['form']['operating_unit_ids'] or False + return result diff --git a/account_operating_unit/wizard/account_report_common_view.xml b/account_operating_unit/wizard/account_report_common_view.xml new file mode 100644 index 0000000000..c3f181fcd9 --- /dev/null +++ b/account_operating_unit/wizard/account_report_common_view.xml @@ -0,0 +1,21 @@ + + + + + + Common Report + account.common.report + + + + + + + + + + + + + + From 590cb77204de1106c5c71887227849b6f2c12db4 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 30 Dec 2015 12:43:29 +0100 Subject: [PATCH 002/130] [FIX] various fixes to ensure that unit tests pass --- account_operating_unit/README.rst | 2 +- account_operating_unit/__openerp__.py | 3 -- .../demo/account_minimal.xml | 26 ---------- account_operating_unit/models/account_move.py | 51 ++++++++++++------- .../tests/test_account_operating_unit.py | 9 ++-- .../tests/test_invoice_operating_unit.py | 2 +- .../tests/test_operating_unit_security.py | 4 +- 7 files changed, 42 insertions(+), 55 deletions(-) delete mode 100644 account_operating_unit/demo/account_minimal.xml diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 5fd576213c..9b02b50da6 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -59,7 +59,7 @@ Images Contributors ------------ -* Eficent +* Eficent Business and IT Consulting Services S.L. * Serpent Consulting Services Pvt. Ltd. Maintainer diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index 4e2d8fd6e8..8522eb5d5b 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -23,8 +23,5 @@ "wizard/account_report_common_view.xml", "wizard/account_financial_report_view.xml", ], - "demo": [ - "demo/account_minimal.xml", - ], "installable": True, } diff --git a/account_operating_unit/demo/account_minimal.xml b/account_operating_unit/demo/account_minimal.xml deleted file mode 100644 index a9eed83e11..0000000000 --- a/account_operating_unit/demo/account_minimal.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - X1115 - Inter-OU Clearing - (test) - - - - - - - - diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 3be84c658c..7a4af65474 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -53,7 +53,7 @@ def post(self): operating_unit = line.operating_unit_id if operating_unit: cl_acc = line.company_id.inter_ou_clearing_account_id - if not cl_acc: + if len(ou_list_ids) > 1 and not cl_acc: raise UserError(_('Configuration error!\n\ You need to define an inter-operating unit clearing\ account in the company settings.')) @@ -93,34 +93,47 @@ def post(self): def _check_same_ou_dr_cr(self): dr = {} cr = {} - ou_ids = [] + account_ids = [] + ou_ids = [line.operating_unit_id.id for line in self.line_ids + if line.operating_unit_id] + ou_ids = list(set(ou_ids)) + for line in self.line_ids: + account_ids.append(line.account_id.id) + if line.account_id.id not in dr: + dr[line.account_id.id] = {} + if line.account_id.id not in cr: + cr[line.account_id.id] = {} operating_unit_id = line.operating_unit_id and \ line.operating_unit_id.id if operating_unit_id: cl_acc = line.company_id.inter_ou_clearing_account_id - if not cl_acc: + if len(ou_ids) > 1 and not cl_acc: raise UserError(_('Configuration error!\n\ You need to define an inter-operating\ unit clearing account in the company settings.')) - ou_ids.append(operating_unit_id) if not cl_acc: - if operating_unit_id in dr: - dr[operating_unit_id] += line.debit + if operating_unit_id in dr[line.account_id.id]: + dr[line.account_id.id][operating_unit_id] += line.debit else: - dr[operating_unit_id] = line.debit + dr[line.account_id.id][operating_unit_id] = line.debit - if operating_unit_id in cr: - cr[operating_unit_id] += line.credit + if operating_unit_id in cr[line.account_id.id]: + cr[line.account_id.id][operating_unit_id] += \ + line.credit else: - cr[operating_unit_id] = line.credit + cr[line.account_id.id][operating_unit_id] = line.credit + account_ids = list(set(account_ids)) for ou_id in ou_ids: - if ( - ou_id in dr and - ou_id in cr and - dr[ou_id] > 0 and - cr[ou_id] > 0 - ): - raise UserError(_('Configuration error!\nThe same\ - operating unit cannot exist in the debit and credit\ - for the same account.')) + for account_id in account_ids: + if ( + account_id in dr and + account_id in cr and + ou_id in dr[account_id] and + ou_id in cr[account_id] and + dr[account_id][ou_id] > 0 and + cr[account_id][ou_id] > 0 + ): + raise UserError(_('Configuration error!\nThe same\ + operating unit cannot exist in the debit and credit\ + for the same account.')) diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index ec54e4f86b..32d14ed698 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -14,7 +14,7 @@ def setUp(self): self.account_model = self.env['account.account'] # company self.company = self.env.ref('base.main_company') - self.grp_acc_user = self.env.ref('account.group_account_invoice') + self.grp_acc_manager = self.env.ref('account.group_account_manager') # Main Operating Unit self.ou1 = self.env.ref('operating_unit.main_operating_unit') # B2B Operating Unit @@ -38,7 +38,7 @@ def setUp(self): 'company_id': self.company.id, 'company_ids': [(4, self.company.id)], 'operating_unit_ids': [(4, self.b2b.id), (4, self.b2c.id)], - 'groups_id': [(6, 0, [self.grp_acc_user.id])] + 'groups_id': [(6, 0, [self.grp_acc_manager.id])] }) # Create cash - test account user_type = self.env.ref('account.data_account_type_liquidity') @@ -56,6 +56,9 @@ def setUp(self): 'user_type_id': user_type.id, 'company_id': self.company.id }) + # Assign the Inter-OU Clearing account to the company + self.company.inter_ou_clearing_account_id = self.inter_ou_account_id.id + # Create user2 self.user2_id =\ self.res_users_model.with_context({'no_reset_password': True}).\ @@ -67,5 +70,5 @@ def setUp(self): 'company_id': self.company.id, 'company_ids': [(4, self.company.id)], 'operating_unit_ids': [(4, self.b2c.id)], - 'groups_id': [(6, 0, [self.grp_acc_user.id])] + 'groups_id': [(6, 0, [self.grp_acc_manager.id])] }) diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index 114d5d7eee..ea5743a3a7 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -46,7 +46,7 @@ def test_create_invoice_validate(self): self.invoice =\ self.invoice_model.sudo(self.user_id.id).create(inv_vals) # Validate the invoice - self.invoice.signal_workflow('invoice_open') + self.invoice.sudo(self.user_id.id).signal_workflow('invoice_open') # Check Operating Units in journal entries all_op_units = all(move_line.operating_unit_id.id == self.b2b.id for move_line in self.invoice.move_id.line_ids) diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py index a3810bd9d4..86bf6e42a3 100644 --- a/account_operating_unit/tests/test_operating_unit_security.py +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -14,5 +14,5 @@ def test_security(self): # Journal Entries from Operating Unit B2B. move_ids = self.aml_model.sudo(self.user2_id.id).\ search([('operating_unit_id', '=', self.b2b.id)]) - self.assertEqual(move_ids, [], 'user_2 should not have access to ' - 'OU %s' % self.b2b.name) + self.assertFalse(move_ids, 'user_2 should not have access to OU %s' + % self.b2b.name) From 792afc31614dbb86313d348b47df73a2e7056868 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 30 Dec 2015 12:48:37 +0100 Subject: [PATCH 003/130] [IMP] changed Eficent copyright --- account_operating_unit/__init__.py | 3 ++- account_operating_unit/__openerp__.py | 6 ++++-- account_operating_unit/models/__init__.py | 3 ++- account_operating_unit/models/account_account.py | 3 ++- account_operating_unit/models/account_move.py | 3 ++- account_operating_unit/models/company.py | 3 ++- account_operating_unit/models/invoice.py | 3 ++- account_operating_unit/tests/__init__.py | 3 ++- account_operating_unit/tests/test_account_operating_unit.py | 3 ++- account_operating_unit/tests/test_cross_ou_journal_entry.py | 3 ++- account_operating_unit/tests/test_invoice_operating_unit.py | 3 ++- .../tests/test_operating_unit_security.py | 3 ++- account_operating_unit/wizard/__init__.py | 3 ++- account_operating_unit/wizard/account_financial_report.py | 3 ++- account_operating_unit/wizard/account_report_common.py | 3 ++- 15 files changed, 32 insertions(+), 16 deletions(-) diff --git a/account_operating_unit/__init__.py b/account_operating_unit/__init__.py index 5c7a28df15..7df5bac8ca 100644 --- a/account_operating_unit/__init__.py +++ b/account_operating_unit/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index 8522eb5d5b..586accb0d6 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). @@ -8,7 +9,8 @@ "summary": "An operating unit (OU) is an organizational entity part of a\ company", "version": "9.0.1.0.0", - "author": "Eficent, Serpent Consulting Services Pvt. Ltd.," + "author": "Eficent Business and IT Consulting Services S.L., " + "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Generic/Sales & Purchases", diff --git a/account_operating_unit/models/__init__.py b/account_operating_unit/models/__init__.py index 12ea5ff604..70e5c7f58a 100644 --- a/account_operating_unit/models/__init__.py +++ b/account_operating_unit/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import company diff --git a/account_operating_unit/models/account_account.py b/account_operating_unit/models/account_account.py index 116eb6059c..016f2a35ad 100644 --- a/account_operating_unit/models/account_account.py +++ b/account_operating_unit/models/account_account.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 7a4af65474..c70ef0586a 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.tools.translate import _ diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index ffd56d47a5..08d4710699 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index 37dd79f786..6c926ef8b4 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models diff --git a/account_operating_unit/tests/__init__.py b/account_operating_unit/tests/__init__.py index 233eca4b1b..de3864c903 100644 --- a/account_operating_unit/tests/__init__.py +++ b/account_operating_unit/tests/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index 32d14ed698..4865b9ffb6 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account.tests import account_test_classes diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py index dba1400fed..c0ae3b9d3f 100644 --- a/account_operating_unit/tests/test_cross_ou_journal_entry.py +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index ea5743a3a7..da2ad3da04 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py index 86bf6e42a3..6ac0decef2 100644 --- a/account_operating_unit/tests/test_operating_unit_security.py +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ diff --git a/account_operating_unit/wizard/__init__.py b/account_operating_unit/wizard/__init__.py index 61d0577d10..2dc29bfebb 100644 --- a/account_operating_unit/wizard/__init__.py +++ b/account_operating_unit/wizard/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import account_report_common diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py index d8703956cd..dcca2ba8cf 100644 --- a/account_operating_unit/wizard/account_financial_report.py +++ b/account_operating_unit/wizard/account_financial_report.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/wizard/account_report_common.py b/account_operating_unit/wizard/account_report_common.py index 3f0449cb3c..86e3d4e5db 100644 --- a/account_operating_unit/wizard/account_report_common.py +++ b/account_operating_unit/wizard/account_report_common.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models From 5f7017934191cd2f6924ee09836062c7eb2d0b26 Mon Sep 17 00:00:00 2001 From: Darshan Patel Date: Tue, 12 Jan 2016 19:25:47 +0530 Subject: [PATCH 004/130] [IMP] : Migrated the code to version 9 --- account_operating_unit/README.rst | 2 +- account_operating_unit/models/account_move.py | 25 +++++++++++++++++++ account_operating_unit/models/company.py | 14 ++++++++++- .../views/account_move_view.xml | 3 +++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 9b02b50da6..b98131ee56 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -45,7 +45,7 @@ check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed `feedback `_. Credits diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index c70ef0586a..72c27b8465 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -11,6 +11,15 @@ class AccountMoveLine(models.Model): _inherit = "account.move.line" + @api.model + def create(self, vals): + + if vals.get('move_id', False): + move = self.env['account.move'].browse(vals['move_id']) + if move.operating_unit_id: + vals['operating_unit_id'] = move.operating_unit_id.id + return super(AccountMoveLine, self).create(vals) + @api.model def _query_get(self, domain=None): if self._context.get('operating_unit_ids', False): @@ -33,10 +42,26 @@ def _check_company_operating_unit(self): raise UserError(_('Configuration error!\nThe Company in the\ Move Line and in the Operating Unit must be the same.')) + @api.one + @api.constrains('operating_unit_id', 'move_id') + def _check_move_operating_unit(self): + if self.move_id and self.move_id.operating_unit_id and \ + self.operating_unit_id and \ + self.move_id.operating_unit_id != \ + self.operating_unit_id: + raise UserError(_('Configuration error!\nThe Operating Unit in the\ + Move Line and in the Move must be the same.')) + class AccountMove(models.Model): _inherit = "account.move" + operating_unit_id = fields.Many2one('operating.unit', + 'Default Operating Unit', + help="This operating unit will " + "be defaulted in the move " + "lines.") + @api.multi def post(self): ml_obj = self.env['account.move.line'] diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index 08d4710699..b322c83cb5 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -3,7 +3,7 @@ # - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models +from openerp import api, fields, models class ResCompany(models.Model): @@ -12,3 +12,15 @@ class ResCompany(models.Model): inter_ou_clearing_account_id = fields.Many2one('account.account', 'Inter-operating unit\ clearing account') + + ou_is_self_balanced = fields.Boolean('Operating Units are self-balanced', + help="Activate if your company is required to generate a " + "balanced balance sheet for each operating unit.", + default = True) + + @api.one + @api.constrains('ou_is_self_balanced') + def _inter_ou_clearing_acc_required(self): + if self.ou_is_self_balanced and not \ + self.inter_ou_clearing_account_id: + return False diff --git a/account_operating_unit/views/account_move_view.xml b/account_operating_unit/views/account_move_view.xml index 94e337003c..f7095e35e7 100644 --- a/account_operating_unit/views/account_move_view.xml +++ b/account_operating_unit/views/account_move_view.xml @@ -57,6 +57,9 @@ account.move + + + - diff --git a/account_operating_unit/views/company_view.xml b/account_operating_unit/views/company_view.xml index 4c1f18a654..b51e24f697 100644 --- a/account_operating_unit/views/company_view.xml +++ b/account_operating_unit/views/company_view.xml @@ -8,6 +8,7 @@ + From b58bde3fe015e2f8b6c9076d8eaaf9e49b0314c7 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 22 Jan 2016 16:53:03 +0100 Subject: [PATCH 006/130] [FIX] travis errors --- account_operating_unit/README.rst | 32 +++++++++---------- account_operating_unit/models/account_move.py | 9 +++--- account_operating_unit/models/company.py | 9 +++--- .../tests/test_account_operating_unit.py | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 722aa3d341..06674febe0 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -7,17 +7,17 @@ Accounting with Operating Units =============================== This module introduces the following features: -- Adds the Operating Unit in the account move line. -- Defines if the operating units are self-balanced and Inter-operating unit +* Adds the Operating Unit in the account move line. +* Defines if the operating units are self-balanced and Inter-operating unit clearing account at company level. -- When users create a journal entry with lines in different operating units, +* When users create a journal entry with lines in different operating units, if operating units have been defined to be self-balanced, at the time of posting the journal entry it automatically creates the corresponding lines in the Inter-operating unit clearing account, making each OU self-balanced. -- The account financial reports include the option to filter by OU. -- Adds the Operating Unit in the invoice -- Implements security rules in the invoice +* The account financial reports include the option to filter by OU. +* Adds the Operating Unit in the invoice +* Implements security rules in the invoice Installation ============ @@ -32,22 +32,22 @@ operating unit you can specify at company level that operating units should be self-balanced, and then indicate a self-balancing clearing account. * Create an account for "Inter-OU Clearing" of type Regular. -* Go to *Settings / Companies / Companies* and: -** Set the "Operating Units are self-balanced" checkbox -** Set the "Inter-OU Clearing" account in "Inter-operating unit clearing -account" field. - +* Go to *Settings / Companies / Companies* and Set the "Operating Units are +self-balanced" checkbox. Then Set the "Inter-OU Clearing" account in +"Inter-operating unit clearing account" field. * Assign Operating Unit in Accounts. Usage ===== -Every accounting entry must balance both at the total level and at the level -of the operating units defined in the journal entry. -If the accounting entry does not balance at the level of the operating units, -additional account entries are created automatically to balance the accounting -entry. +* Add the Operating Unit to invoices +* Add the Default Operating Unit to account move. Then all move lines will +by default adopt this Operating Unit +* Add Operating Units to the move lines. If they differ across lines of the +same move, and the OU's are self-balanced, then additional move lines will +be created so as to make the move self-balanced from OU perspective. + .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index aa1590ef45..8138383b3b 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -42,10 +42,11 @@ def _check_company_operating_unit(self): @api.one @api.constrains('operating_unit_id', 'move_id') def _check_move_operating_unit(self): - if self.move_id and self.move_id.operating_unit_id and \ - self.operating_unit_id and \ - self.move_id.operating_unit_id != \ - self.operating_unit_id: + if ( + self.move_id and self.move_id.operating_unit_id and + self.operating_unit_id and + self.move_id.operating_unit_id != self.operating_unit_id + ): raise UserError(_('Configuration error!\nThe Operating Unit in\ the Move Line and in the Move must be the same.')) diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index 78c586567a..b36a565e44 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -15,10 +15,11 @@ class ResCompany(models.Model): 'Inter-operating unit\ clearing account') - ou_is_self_balanced = fields.Boolean('Operating Units are self-balanced', - help="Activate if your company is required to generate a " - "balanced balance sheet for each operating unit.", - default=True) + ou_is_self_balanced = fields.Boolean( + 'Operating Units are self-balanced', + help="Activate if your company is required to generate a " + "balanced balance sheet for each operating unit.", + default=True) @api.one @api.constrains('ou_is_self_balanced') diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index a78ea69ed8..5115995003 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -59,7 +59,7 @@ def setUp(self): }) # Assign the Inter-OU Clearing account to the company self.company.inter_ou_clearing_account_id = self.inter_ou_account_id.id - self.company.ou_is_self_balanced = self.ou_is_self_balanced.id + self.company.ou_is_self_balanced = True # Create user2 self.user2_id =\ From 2e35642d6b6bc015434724f6995c3ba968cebc4d Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 22 Jan 2016 18:01:36 +0100 Subject: [PATCH 007/130] [FIX] remove period_id --- account_operating_unit/models/account_move.py | 1 - 1 file changed, 1 deletion(-) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 8138383b3b..b11bf38f0b 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -71,7 +71,6 @@ def _prepare_inter_ou_balancing_move_line(self, move, ou_id, 'name': 'OU-Balancing', 'move_id': move.id, 'journal_id': move.journal_id.id, - 'period_id': move.period_id.id, 'date': move.date, 'operating_unit_id': ou_id, 'account_id': move.company_id.inter_ou_clearing_account_id.id From 3aa55add50a41b463b323323ee272ff8151b9a7e Mon Sep 17 00:00:00 2001 From: jbeficent Date: Mon, 25 Jan 2016 09:42:27 +0100 Subject: [PATCH 008/130] [FIX] Applied review comments by @elicoidal --- account_operating_unit/README.rst | 27 +++++++++---------- account_operating_unit/__init__.py | 4 +-- account_operating_unit/__openerp__.py | 10 +++---- account_operating_unit/models/__init__.py | 4 +-- .../models/account_account.py | 4 +-- account_operating_unit/models/account_move.py | 11 ++++---- account_operating_unit/models/company.py | 4 +-- account_operating_unit/models/invoice.py | 4 +-- account_operating_unit/tests/__init__.py | 4 +-- .../tests/test_account_operating_unit.py | 4 +-- .../tests/test_cross_ou_journal_entry.py | 4 +-- .../tests/test_invoice_operating_unit.py | 4 +-- .../tests/test_operating_unit_security.py | 4 +-- account_operating_unit/wizard/__init__.py | 4 +-- .../wizard/account_financial_report.py | 4 +-- .../wizard/account_report_common.py | 4 +-- 16 files changed, 49 insertions(+), 51 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 06674febe0..417f2fea7c 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -7,34 +7,33 @@ Accounting with Operating Units =============================== This module introduces the following features: -* Adds the Operating Unit in the account move line. -* Defines if the operating units are self-balanced and Inter-operating unit +* Adds the Operating Unit (OU) to the account move line. +* Defines if the Operating Units are self-balanced and Inter-Operating Unit clearing account at company level. -* When users create a journal entry with lines in different operating units, -if operating units have been defined to be self-balanced, -at the time of posting the journal entry it automatically creates the -corresponding lines in the Inter-operating unit clearing account, -making each OU self-balanced. +* Journal entry with lines in different Operating Units are checked based on +the "self-balanced" set up in OU. At the time of posting the journal entry, +the corresponding lines in the Inter-Operating Unit clearing account are +automatically created, making each OU self-balanced. * The account financial reports include the option to filter by OU. -* Adds the Operating Unit in the invoice -* Implements security rules in the invoice +* Adds the Operating Unit (OU) to the invoice +* Implements security rules in the invoice based on OU. Installation ============ -No external library is used. +No specific installation requirements. Configuration ============= If your company is required to generate a balanced balance sheet by -operating unit you can specify at company level that operating units should +Operating Unit you can specify at company level that Operating Units should be self-balanced, and then indicate a self-balancing clearing account. * Create an account for "Inter-OU Clearing" of type Regular. * Go to *Settings / Companies / Companies* and Set the "Operating Units are self-balanced" checkbox. Then Set the "Inter-OU Clearing" account in -"Inter-operating unit clearing account" field. +"Inter-Operating Unit clearing account" field. * Assign Operating Unit in Accounts. @@ -85,7 +84,7 @@ Maintainer .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. @@ -93,4 +92,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. \ No newline at end of file diff --git a/account_operating_unit/__init__.py b/account_operating_unit/__init__.py index 7df5bac8ca..313eee8204 100644 --- a/account_operating_unit/__init__.py +++ b/account_operating_unit/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models from . import wizard diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index 586accb0d6..0617cf8662 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -1,19 +1,19 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": 'Accounting with Operating Units', - "summary": "An operating unit (OU) is an organizational entity part of a\ - company", + "summary": "Introduces Operating Unit fields in invoices and " + "Accounting Entries with clearing account", "version": "9.0.1.0.0", "author": "Eficent Business and IT Consulting Services S.L., " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", "website": "http://www.eficent.com", - "category": "Generic/Sales & Purchases", + "category": "Accounting & Finance", "depends": ['account', 'operating_unit'], "license": "LGPL-3", "data": [ diff --git a/account_operating_unit/models/__init__.py b/account_operating_unit/models/__init__.py index 70e5c7f58a..14ec5df6cf 100644 --- a/account_operating_unit/models/__init__.py +++ b/account_operating_unit/models/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import company from . import account_account diff --git a/account_operating_unit/models/account_account.py b/account_operating_unit/models/account_account.py index 016f2a35ad..cf21a0f06b 100644 --- a/account_operating_unit/models/account_account.py +++ b/account_operating_unit/models/account_account.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index b11bf38f0b..6f443cc321 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.tools.translate import _ from openerp import api, fields, models @@ -55,10 +55,9 @@ class AccountMove(models.Model): _inherit = "account.move" operating_unit_id = fields.Many2one('operating.unit', - 'Default Operating Unit', - help="This operating unit will " - "be defaulted in the move " - "lines.") + 'Default Operating Unit', + help="This operating unit will " + "be defaulted in the move lines.") @api.multi def _prepare_inter_ou_balancing_move_line(self, move, ou_id, diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index b36a565e44..b361077822 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models from openerp.tools.translate import _ diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index 6c926ef8b4..9714b61486 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models diff --git a/account_operating_unit/tests/__init__.py b/account_operating_unit/tests/__init__.py index de3864c903..57c9e3f0d4 100644 --- a/account_operating_unit/tests/__init__.py +++ b/account_operating_unit/tests/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit from . import test_invoice_operating_unit diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index 5115995003..59697b520d 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account.tests import account_test_classes diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py index c0ae3b9d3f..5c40ec8429 100644 --- a/account_operating_unit/tests/test_cross_ou_journal_entry.py +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index da2ad3da04..08602ae5ff 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py index 6ac0decef2..d96a4ba4e1 100644 --- a/account_operating_unit/tests/test_operating_unit_security.py +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ test_account_operating_unit as test_ou diff --git a/account_operating_unit/wizard/__init__.py b/account_operating_unit/wizard/__init__.py index 2dc29bfebb..db7122592e 100644 --- a/account_operating_unit/wizard/__init__.py +++ b/account_operating_unit/wizard/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import account_report_common from . import account_financial_report diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py index dcca2ba8cf..bf0f5cbd57 100644 --- a/account_operating_unit/wizard/account_financial_report.py +++ b/account_operating_unit/wizard/account_financial_report.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/wizard/account_report_common.py b/account_operating_unit/wizard/account_report_common.py index 86e3d4e5db..6c3cbca114 100644 --- a/account_operating_unit/wizard/account_report_common.py +++ b/account_operating_unit/wizard/account_report_common.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models From 4c6feddb8a16be7c3edee8ae03cc71fd62337c12 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Mon, 25 Jan 2016 10:38:22 +0100 Subject: [PATCH 009/130] [FIX] errors in creation of account move --- account_operating_unit/models/account_account.py | 3 +-- account_operating_unit/models/account_move.py | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/account_operating_unit/models/account_account.py b/account_operating_unit/models/account_account.py index cf21a0f06b..94ddc76836 100644 --- a/account_operating_unit/models/account_account.py +++ b/account_operating_unit/models/account_account.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Eficent Business and IT Consulting Services S.L. (www.eficent.com) # - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 6f443cc321..c187daef23 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -109,6 +109,7 @@ def post(self): # Create balancing entries for un-balanced OU's. ou_balances = self._check_ou_balance(move) + amls = [] for ou_id in ou_balances.keys(): # If the OU is already balanced, then do not continue if move.company_id.currency_id.is_zero(ou_balances[ou_id]): @@ -118,8 +119,10 @@ def post(self): line_data = self._prepare_inter_ou_balancing_move_line( move, ou_id, ou_balances) if line_data: - lid = ml_obj.create(line_data) - move.write({'line_ids': [(4, lid)]}) + amls.append(ml_obj.create(line_data)) + if amls: + move.write({'line_ids': [(4, aml.id) for aml in amls]}) + return super(AccountMove, self).post() From 0b556b2f2454c4438b27d318db524614a5e5c6d8 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Mon, 25 Jan 2016 10:54:45 +0100 Subject: [PATCH 010/130] [FIX] README.RST style --- account_operating_unit/README.rst | 38 +++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 417f2fea7c..27b0b5be02 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -7,15 +7,23 @@ Accounting with Operating Units =============================== This module introduces the following features: + * Adds the Operating Unit (OU) to the account move line. + * Defines if the Operating Units are self-balanced and Inter-Operating Unit -clearing account at company level. + clearing account at company level. + * Journal entry with lines in different Operating Units are checked based on -the "self-balanced" set up in OU. At the time of posting the journal entry, -the corresponding lines in the Inter-Operating Unit clearing account are -automatically created, making each OU self-balanced. + the "self-balanced" set up in OU. + + At the time of posting the journal entry, the corresponding lines in the + Inter-Operating Unit clearing account are automatically created, making + each OU self-balanced. + * The account financial reports include the option to filter by OU. -* Adds the Operating Unit (OU) to the invoice + +* Adds the Operating Unit (OU) to the invoice. + * Implements security rules in the invoice based on OU. Installation @@ -31,23 +39,29 @@ Operating Unit you can specify at company level that Operating Units should be self-balanced, and then indicate a self-balancing clearing account. * Create an account for "Inter-OU Clearing" of type Regular. + * Go to *Settings / Companies / Companies* and Set the "Operating Units are -self-balanced" checkbox. Then Set the "Inter-OU Clearing" account in -"Inter-Operating Unit clearing account" field. + self-balanced" checkbox. + + Then Set the "Inter-OU Clearing" account in "Inter-Operating Unit + clearing account" field. + * Assign Operating Unit in Accounts. Usage ===== -* Add the Operating Unit to invoices +* Add the Operating Unit to invoices. + * Add the Default Operating Unit to account move. Then all move lines will -by default adopt this Operating Unit -* Add Operating Units to the move lines. If they differ across lines of the -same move, and the OU's are self-balanced, then additional move lines will -be created so as to make the move self-balanced from OU perspective. + by default adopt this Operating Unit. +* Add Operating Units to the move lines. + If they differ across lines of the same move, and the OU's are + self-balanced, then additional move lines will be created so as to make + the move self-balanced from OU perspective. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot From 2161e89b14e8e7c8edcbf21042e2754f8ecda24b Mon Sep 17 00:00:00 2001 From: jbeficent Date: Mon, 25 Jan 2016 11:06:47 +0100 Subject: [PATCH 011/130] [FIX] travis errors --- account_operating_unit/models/account_move.py | 3 +-- account_operating_unit/models/company.py | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index c187daef23..35e8920fb1 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -117,13 +117,12 @@ def post(self): # Create a balancing move line in the operating unit # clearing account line_data = self._prepare_inter_ou_balancing_move_line( - move, ou_id, ou_balances) + move, ou_id, ou_balances) if line_data: amls.append(ml_obj.create(line_data)) if amls: move.write({'line_ids': [(4, aml.id) for aml in amls]}) - return super(AccountMove, self).post() @api.one diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index b361077822..157d3ec189 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -15,11 +15,12 @@ class ResCompany(models.Model): 'Inter-operating unit\ clearing account') - ou_is_self_balanced = fields.Boolean( - 'Operating Units are self-balanced', - help="Activate if your company is required to generate a " - "balanced balance sheet for each operating unit.", - default=True) + ou_is_self_balanced = fields.Boolean('Operating Units are self-balanced', + help="Activate if your company is " + "required to generate a balanced" + " balance sheet for each " + "operating unit.", + default=True) @api.one @api.constrains('ou_is_self_balanced') From 6f0ca7c3875debec4c26b3fc03f913cb12da5398 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Mon, 25 Jan 2016 11:50:45 +0100 Subject: [PATCH 012/130] [FIX] travis --- account_operating_unit/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 35e8920fb1..407cc9feef 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -117,7 +117,7 @@ def post(self): # Create a balancing move line in the operating unit # clearing account line_data = self._prepare_inter_ou_balancing_move_line( - move, ou_id, ou_balances) + move, ou_id, ou_balances) if line_data: amls.append(ml_obj.create(line_data)) if amls: From 875bd14949969f1dcf4fcea9694980c839d36086 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Thu, 4 Feb 2016 19:23:47 +0100 Subject: [PATCH 013/130] [IMP] add invoice analysis by operating unit --- account_operating_unit/__openerp__.py | 1 + account_operating_unit/report/__init__.py | 7 +++ .../report/account_invoice_report.py | 51 +++++++++++++++++++ .../views/account_invoice_report_view.xml | 24 +++++++++ 4 files changed, 83 insertions(+) create mode 100644 account_operating_unit/report/__init__.py create mode 100644 account_operating_unit/report/account_invoice_report.py create mode 100644 account_operating_unit/views/account_invoice_report_view.xml diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index 0617cf8662..81f4c70f42 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -22,6 +22,7 @@ "views/account_account_view.xml", "views/company_view.xml", "views/invoice_view.xml", + "views/account_invoice_report_view.xml", "wizard/account_report_common_view.xml", "wizard/account_financial_report_view.xml", ], diff --git a/account_operating_unit/report/__init__.py b/account_operating_unit/report/__init__.py new file mode 100644 index 0000000000..3b9390b5a4 --- /dev/null +++ b/account_operating_unit/report/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import account_invoice_report diff --git a/account_operating_unit/report/account_invoice_report.py b/account_operating_unit/report/account_invoice_report.py new file mode 100644 index 0000000000..3f0ba8e155 --- /dev/null +++ b/account_operating_unit/report/account_invoice_report.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import fields, models + + +class AccountInvoiceReport(models.Model): + + _inherit = "account.invoice.report" + + operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit') + + def _select(self): + select_str = super(AccountInvoiceReport, self)._select() + select_str += """ + ,sub.operating_unit_id + """ + return select_str + + def _sub_select(self): + select_str = super(AccountInvoiceReport, self)._sub_select() + select_str += """ + ,ai.operating_unit_id + """ + return select_str + + + def _group_by(self): + group_by_str = super(AccountInvoiceReport, self)._group_by() + group_by_str += """ + ,ai.operating_unit_id + """ + return group_by_str diff --git a/account_operating_unit/views/account_invoice_report_view.xml b/account_operating_unit/views/account_invoice_report_view.xml new file mode 100644 index 0000000000..d46dfa3fc3 --- /dev/null +++ b/account_operating_unit/views/account_invoice_report_view.xml @@ -0,0 +1,24 @@ + + + + + + account.invoice.report.search + account.invoice.report + + + + + + + + + + + + + From 5d4162a2900e27c8fff3560f61c1e5c162b30d95 Mon Sep 17 00:00:00 2001 From: aheficent Date: Wed, 17 Aug 2016 18:10:07 +0200 Subject: [PATCH 014/130] [FIX] Do not assert_balance until all journal items exist. Fix search view in report. Other minor fixes. --- account_operating_unit/README.rst | 12 ++--- account_operating_unit/__init__.py | 2 + account_operating_unit/models/account_move.py | 44 ++++++++++++------- account_operating_unit/models/invoice.py | 15 +++---- .../report/account_invoice_report.py | 1 - .../security/account_security.xml | 2 +- .../views/account_invoice_report_view.xml | 2 +- 7 files changed, 44 insertions(+), 34 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 27b0b5be02..28eee58c54 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -38,15 +38,15 @@ If your company is required to generate a balanced balance sheet by Operating Unit you can specify at company level that Operating Units should be self-balanced, and then indicate a self-balancing clearing account. -* Create an account for "Inter-OU Clearing" of type Regular. +1. Create an account for "Inter-OU Clearing" of type Non-current assets. -* Go to *Settings / Companies / Companies* and Set the "Operating Units are - self-balanced" checkbox. +2. Go to *Settings / Companies / Configuration* and Set the "Operating Units + are self-balanced" checkbox. - Then Set the "Inter-OU Clearing" account in "Inter-Operating Unit - clearing account" field. + Then set the "Inter-OU Clearing" account in "Inter-Operating Unit + clearing account" field. -* Assign Operating Unit in Accounts. +3. Assign Operating Unit in Accounts. Usage diff --git a/account_operating_unit/__init__.py b/account_operating_unit/__init__.py index 313eee8204..0a28cfa289 100644 --- a/account_operating_unit/__init__.py +++ b/account_operating_unit/__init__.py @@ -3,5 +3,7 @@ # - Jordi Ballester Alomar # © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from . import models from . import wizard +from . import report diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 407cc9feef..b0f5d2a18a 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -26,36 +26,41 @@ def create(self, vals): @api.model def _query_get(self, domain=None): + if domain == None: + domain = [] if self._context.get('operating_unit_ids', False): domain.append(('operating_unit_id', 'in', self._context.get('operating_unit_ids'))) return super(AccountMoveLine, self)._query_get(domain) - @api.one + @api.multi @api.constrains('operating_unit_id', 'company_id') def _check_company_operating_unit(self): - if self.company_id and self.operating_unit_id and \ - self.company_id != self.operating_unit_id.company_id: - raise UserError(_('Configuration error!\nThe Company in the\ - Move Line and in the Operating Unit must be the same.')) + for rec in self: + if rec.company_id and rec.operating_unit_id and \ + rec.company_id != rec.operating_unit_id.company_id: + raise UserError(_('Configuration error!\nThe Company in the' + ' Move Line and in the Operating Unit must ' + 'be the same.')) - @api.one + @api.multi @api.constrains('operating_unit_id', 'move_id') def _check_move_operating_unit(self): - if ( - self.move_id and self.move_id.operating_unit_id and - self.operating_unit_id and - self.move_id.operating_unit_id != self.operating_unit_id + for rec in self: + if (rec.move_id and rec.move_id.operating_unit_id and + rec.operating_unit_id and + rec.move_id.operating_unit_id != self.operating_unit_id ): - raise UserError(_('Configuration error!\nThe Operating Unit in\ - the Move Line and in the Move must be the same.')) + raise UserError(_('Configuration error!\nThe Operating Unit in' + ' the Move Line and in the Move must be the' + ' same.')) class AccountMove(models.Model): _inherit = "account.move" operating_unit_id = fields.Many2one('operating.unit', - 'Default Operating Unit', + 'Default operating unit', help="This operating unit will " "be defaulted in the move lines.") @@ -119,13 +124,20 @@ def post(self): line_data = self._prepare_inter_ou_balancing_move_line( move, ou_id, ou_balances) if line_data: - amls.append(ml_obj.create(line_data)) + amls.append(ml_obj.with_context(wip = True). + create(line_data)) if amls: - move.write({'line_ids': [(4, aml.id) for aml in amls]}) + move.with_context(wip = False).\ + write({'line_ids': [(4, aml.id) for aml in amls]}) return super(AccountMove, self).post() - @api.one + def assert_balanced(self): + if self.env.context.get('wip'): + return True + return super(AccountMove, self).assert_balanced() + + @api.multi @api.constrains('line_ids') def _check_ou(self): for move in self: diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index 9714b61486..59415492d6 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -4,6 +4,8 @@ # © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models +from openerp.exceptions import ValidationError +from openerp.tools.translate import _ class AccountInvoice(models.Model): @@ -27,23 +29,18 @@ def finalize_invoice_move_lines(self, move_lines): return new_move_lines @api.multi + @api.constrains('operating_unit_id', 'company_id') def _check_company_operating_unit(self): - for pr in self.browse(): + for pr in self: if ( pr.company_id and pr.operating_unit_id and pr.company_id != pr.operating_unit_id.company_id ): - return False + raise ValidationError(_('The Company in the Invoice and in ' + 'Operating Unit must be the same.')) return True - _constraints = [ - (_check_company_operating_unit, - 'The Company in the Invoice and in the Operating ' - 'Unit must be the same.', ['operating_unit_id', - 'company_id'])] - - class AccountInvoiceLine(models.Model): _inherit = 'account.invoice.line' diff --git a/account_operating_unit/report/account_invoice_report.py b/account_operating_unit/report/account_invoice_report.py index 3f0ba8e155..ea16f1b5d5 100644 --- a/account_operating_unit/report/account_invoice_report.py +++ b/account_operating_unit/report/account_invoice_report.py @@ -42,7 +42,6 @@ def _sub_select(self): """ return select_str - def _group_by(self): group_by_str = super(AccountInvoiceReport, self)._group_by() group_by_str += """ diff --git a/account_operating_unit/security/account_security.xml b/account_operating_unit/security/account_security.xml index 24f9b7c9dc..250fbaaf69 100644 --- a/account_operating_unit/security/account_security.xml +++ b/account_operating_unit/security/account_security.xml @@ -27,7 +27,7 @@ ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Move Lines from allowed operating units + Move lines from allowed operating units diff --git a/account_operating_unit/views/account_invoice_report_view.xml b/account_operating_unit/views/account_invoice_report_view.xml index d46dfa3fc3..1d2d35a934 100644 --- a/account_operating_unit/views/account_invoice_report_view.xml +++ b/account_operating_unit/views/account_invoice_report_view.xml @@ -11,7 +11,7 @@ - + Date: Thu, 18 Aug 2016 10:00:01 +0200 Subject: [PATCH 015/130] [FIX] Style fixes suggested by @elicoidal --- account_operating_unit/README.rst | 8 ++----- account_operating_unit/models/company.py | 11 +++++----- .../report/account_invoice_report.py | 21 ++----------------- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 28eee58c54..6ecf983d88 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -71,13 +71,9 @@ Bug Tracker =========== Bugs are tracked on `GitHub Issues -`_. In case of trouble, please +`_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed `feedback -`_. +help us smashing it by providing a detailed and welcomed feedback. Credits ======= diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index 157d3ec189..0bc9df4d42 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -22,10 +22,11 @@ class ResCompany(models.Model): "operating unit.", default=True) - @api.one + @api.multi @api.constrains('ou_is_self_balanced') def _inter_ou_clearing_acc_required(self): - if self.ou_is_self_balanced and not \ - self.inter_ou_clearing_account_id: - raise UserError(_('Configuration error!\nPlease indicate an\ - Inter-operating unit clearing account.')) + for rec in self: + if rec.ou_is_self_balanced and not \ + rec.inter_ou_clearing_account_id: + raise UserError(_('Configuration error!\nPlease indicate an\ + Inter-operating unit clearing account.')) diff --git a/account_operating_unit/report/account_invoice_report.py b/account_operating_unit/report/account_invoice_report.py index ea16f1b5d5..2f81b8734a 100644 --- a/account_operating_unit/report/account_invoice_report.py +++ b/account_operating_unit/report/account_invoice_report.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# 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 for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# Copyright 2016 Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). from openerp import fields, models From 735ae19c6a4992ada64ca7fd5cffd1764a3ff434 Mon Sep 17 00:00:00 2001 From: aheficent Date: Thu, 18 Aug 2016 11:04:40 +0200 Subject: [PATCH 016/130] [FIX] travis issues --- account_operating_unit/models/account_move.py | 13 ++++++------- account_operating_unit/models/invoice.py | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index b0f5d2a18a..04817b63ec 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -26,7 +26,7 @@ def create(self, vals): @api.model def _query_get(self, domain=None): - if domain == None: + if domain is None: domain = [] if self._context.get('operating_unit_ids', False): domain.append(('operating_unit_id', 'in', @@ -37,8 +37,8 @@ def _query_get(self, domain=None): @api.constrains('operating_unit_id', 'company_id') def _check_company_operating_unit(self): for rec in self: - if rec.company_id and rec.operating_unit_id and \ - rec.company_id != rec.operating_unit_id.company_id: + if rec.company_id and rec.operating_unit_id and rec.company_id !=\ + rec.operating_unit_id.company_id: raise UserError(_('Configuration error!\nThe Company in the' ' Move Line and in the Operating Unit must ' 'be the same.')) @@ -49,8 +49,7 @@ def _check_move_operating_unit(self): for rec in self: if (rec.move_id and rec.move_id.operating_unit_id and rec.operating_unit_id and - rec.move_id.operating_unit_id != self.operating_unit_id - ): + rec.move_id.operating_unit_id != self.operating_unit_id): raise UserError(_('Configuration error!\nThe Operating Unit in' ' the Move Line and in the Move must be the' ' same.')) @@ -124,10 +123,10 @@ def post(self): line_data = self._prepare_inter_ou_balancing_move_line( move, ou_id, ou_balances) if line_data: - amls.append(ml_obj.with_context(wip = True). + amls.append(ml_obj.with_context(wip=True). create(line_data)) if amls: - move.with_context(wip = False).\ + move.with_context(wip=False).\ write({'line_ids': [(4, aml.id) for aml in amls]}) return super(AccountMove, self).post() diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index 59415492d6..4ed7cbcba4 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -41,6 +41,7 @@ def _check_company_operating_unit(self): 'Operating Unit must be the same.')) return True + class AccountInvoiceLine(models.Model): _inherit = 'account.invoice.line' From a6158e9c2a6f52ae0362af68038f563be27839d3 Mon Sep 17 00:00:00 2001 From: aheficent Date: Thu, 18 Aug 2016 18:09:24 +0200 Subject: [PATCH 017/130] [FIX] travis issues --- account_operating_unit/models/account_move.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 04817b63ec..66989ac430 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -37,8 +37,8 @@ def _query_get(self, domain=None): @api.constrains('operating_unit_id', 'company_id') def _check_company_operating_unit(self): for rec in self: - if rec.company_id and rec.operating_unit_id and rec.company_id !=\ - rec.operating_unit_id.company_id: + if (rec.company_id and rec.operating_unit_id and rec.company_id != + rec.operating_unit_id.company_id): raise UserError(_('Configuration error!\nThe Company in the' ' Move Line and in the Operating Unit must ' 'be the same.')) @@ -48,8 +48,8 @@ def _check_company_operating_unit(self): def _check_move_operating_unit(self): for rec in self: if (rec.move_id and rec.move_id.operating_unit_id and - rec.operating_unit_id and - rec.move_id.operating_unit_id != self.operating_unit_id): + rec.operating_unit_id and rec.move_id.operating_unit_id != + self.operating_unit_id): raise UserError(_('Configuration error!\nThe Operating Unit in' ' the Move Line and in the Move must be the' ' same.')) From fbbf5cc2808b876d307269ca0338108b31a26483 Mon Sep 17 00:00:00 2001 From: aheficent Date: Fri, 26 Aug 2016 14:54:59 +0200 Subject: [PATCH 018/130] [UPT] By default the OU is not self balanced because the constraint of setting an inter-OU accounts triggers from other modules when creating companies --- account_operating_unit/models/company.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index 0bc9df4d42..8ebf7914f2 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -20,7 +20,7 @@ class ResCompany(models.Model): "required to generate a balanced" " balance sheet for each " "operating unit.", - default=True) + default=False) @api.multi @api.constrains('ou_is_self_balanced') From 99407d95a4e2f83e89e8d4fddf444d513f818db9 Mon Sep 17 00:00:00 2001 From: aheficent Date: Mon, 5 Sep 2016 10:25:21 +0200 Subject: [PATCH 019/130] [UPT] suggested type for inter OU account --- account_operating_unit/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 6ecf983d88..8b92686e6b 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -38,7 +38,7 @@ If your company is required to generate a balanced balance sheet by Operating Unit you can specify at company level that Operating Units should be self-balanced, and then indicate a self-balancing clearing account. -1. Create an account for "Inter-OU Clearing" of type Non-current assets. +1. Create an account for "Inter-OU Clearing" of type Current assets. 2. Go to *Settings / Companies / Configuration* and Set the "Operating Units are self-balanced" checkbox. From e9e38e862ad5f40a6954487a79b23c06d6c0b092 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 9 Sep 2016 17:08:36 +0200 Subject: [PATCH 020/130] [FIX] improve README. Inter OU clearing is a balance sheet account --- account_operating_unit/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 8b92686e6b..891e0c99b1 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -38,7 +38,7 @@ If your company is required to generate a balanced balance sheet by Operating Unit you can specify at company level that Operating Units should be self-balanced, and then indicate a self-balancing clearing account. -1. Create an account for "Inter-OU Clearing" of type Current assets. +1. Create an account "Inter-OU Clearing". It is a balance sheet account. 2. Go to *Settings / Companies / Configuration* and Set the "Operating Units are self-balanced" checkbox. From fc819f67d296fcb92a533fb0c264448b051bbd5e Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 9 Sep 2016 19:00:34 +0200 Subject: [PATCH 021/130] [IMP] Add the operating units in the financial reports qweb --- account_operating_unit/__openerp__.py | 1 + account_operating_unit/views/report_financial.xml | 12 ++++++++++++ .../wizard/account_financial_report.py | 5 +++++ 3 files changed, 18 insertions(+) create mode 100644 account_operating_unit/views/report_financial.xml diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index 81f4c70f42..4d9ce2a0df 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -23,6 +23,7 @@ "views/company_view.xml", "views/invoice_view.xml", "views/account_invoice_report_view.xml", + "views/report_financial.xml", "wizard/account_report_common_view.xml", "wizard/account_financial_report_view.xml", ], diff --git a/account_operating_unit/views/report_financial.xml b/account_operating_unit/views/report_financial.xml new file mode 100644 index 0000000000..9dabeb86a2 --- /dev/null +++ b/account_operating_unit/views/report_financial.xml @@ -0,0 +1,12 @@ + + + + diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py index bf0f5cbd57..ac89f64044 100644 --- a/account_operating_unit/wizard/account_financial_report.py +++ b/account_operating_unit/wizard/account_financial_report.py @@ -30,3 +30,8 @@ def _build_comparison_context(self, data): and data['form']['operating_unit_ids'] \ or False return result + + def _print_report(self, data): + operating_units = ', '.join([ou.name for ou in self.operating_unit_ids]) + data['form'].update({'operating_units': operating_units}) + return super(AccountingReport, self)._print_report(data) From 0c88b9b1eedd65b58667ed9485aff4b644d04a7f Mon Sep 17 00:00:00 2001 From: ahenriquez Date: Mon, 12 Sep 2016 17:13:41 +0200 Subject: [PATCH 022/130] [FIX] travis issues --- account_operating_unit/README.rst | 2 +- account_operating_unit/tests/test_cross_ou_journal_entry.py | 3 +-- account_operating_unit/tests/test_invoice_operating_unit.py | 3 +-- account_operating_unit/tests/test_operating_unit_security.py | 3 +-- account_operating_unit/wizard/account_financial_report.py | 3 ++- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 891e0c99b1..c4a02d19e1 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -102,4 +102,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py index 5c40ec8429..db3689e99d 100644 --- a/account_operating_unit/tests/test_cross_ou_journal_entry.py +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -3,8 +3,7 @@ # - Jordi Ballester Alomar # © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp.addons.account_operating_unit.tests import\ - test_account_operating_unit as test_ou +from . import test_account_operating_unit as test_ou class TestCrossOuJournalEntry(test_ou.TestAccountOperatingUnit): diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index 08602ae5ff..8b8069d23e 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -3,8 +3,7 @@ # - Jordi Ballester Alomar # © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp.addons.account_operating_unit.tests import\ - test_account_operating_unit as test_ou +from . import test_account_operating_unit as test_ou class TestInvoiceOperatingUnit(test_ou.TestAccountOperatingUnit): diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py index d96a4ba4e1..a84a2774f8 100644 --- a/account_operating_unit/tests/test_operating_unit_security.py +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -3,8 +3,7 @@ # - Jordi Ballester Alomar # © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp.addons.account_operating_unit.tests import\ - test_account_operating_unit as test_ou +from . import test_account_operating_unit as test_ou class TestOuSecurity(test_ou.TestAccountOperatingUnit): diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py index ac89f64044..f0273f0a26 100644 --- a/account_operating_unit/wizard/account_financial_report.py +++ b/account_operating_unit/wizard/account_financial_report.py @@ -32,6 +32,7 @@ def _build_comparison_context(self, data): return result def _print_report(self, data): - operating_units = ', '.join([ou.name for ou in self.operating_unit_ids]) + operating_units = ', '.join([ou.name for ou in + self.operating_unit_ids]) data['form'].update({'operating_units': operating_units}) return super(AccountingReport, self)._print_report(data) From 9eba3758311616bd57119f55185c5a5df3cad37b Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 14 Sep 2016 17:41:20 +0200 Subject: [PATCH 023/130] [IMP] various additions, including: * Add management of payments using operating units * Trial Balance by operating units * Improve tests --- account_operating_unit/README.rst | 54 ++++++++--- account_operating_unit/__openerp__.py | 5 +- account_operating_unit/models/__init__.py | 6 +- .../models/account_account.py | 15 --- .../models/account_journal.py | 28 ++++++ account_operating_unit/models/account_move.py | 3 +- .../models/account_payment.py | 95 +++++++++++++++++++ account_operating_unit/models/company.py | 3 +- account_operating_unit/models/invoice.py | 3 +- .../security/account_security.xml | 12 +++ account_operating_unit/tests/__init__.py | 1 + .../tests/test_account_operating_unit.py | 91 +++++++++++++++++- .../tests/test_cross_ou_journal_entry.py | 10 +- .../tests/test_invoice_operating_unit.py | 32 +------ .../tests/test_payment_operating_unit.py | 37 ++++++++ .../views/account_account_view.xml | 17 ---- .../views/account_invoice_report_view.xml | 3 +- .../views/account_journal_view.xml | 20 ++++ .../views/account_move_view.xml | 16 +++- .../views/account_payment_view.xml | 61 ++++++++++++ account_operating_unit/views/invoice_view.xml | 12 ++- .../views/report_agedpartnerbalance.xml | 12 +++ .../views/report_trialbalance.xml | 12 +++ account_operating_unit/wizard/__init__.py | 4 +- .../wizard/account_financial_report_view.xml | 6 +- .../wizard/account_report_common.py | 3 +- .../wizard/account_report_common_view.xml | 11 +-- .../wizard/account_report_trial_balance.py | 30 ++++++ .../account_report_trial_balance_view.xml | 19 ++++ 29 files changed, 507 insertions(+), 114 deletions(-) delete mode 100644 account_operating_unit/models/account_account.py create mode 100644 account_operating_unit/models/account_journal.py create mode 100644 account_operating_unit/models/account_payment.py create mode 100644 account_operating_unit/tests/test_payment_operating_unit.py delete mode 100644 account_operating_unit/views/account_account_view.xml create mode 100644 account_operating_unit/views/account_journal_view.xml create mode 100644 account_operating_unit/views/account_payment_view.xml create mode 100644 account_operating_unit/views/report_agedpartnerbalance.xml create mode 100644 account_operating_unit/views/report_trialbalance.xml create mode 100644 account_operating_unit/wizard/account_report_trial_balance.py create mode 100644 account_operating_unit/wizard/account_report_trial_balance_view.xml diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index c4a02d19e1..fe8e998da5 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -6,25 +6,35 @@ Accounting with Operating Units =============================== -This module introduces the following features: +This module allows a company to manage the accounting based on Operating +Units (OU's). -* Adds the Operating Unit (OU) to the account move line. +* The financial reports (Trial Balance, P&L, Balance Sheet), allow to report + the balances of one or more OU's. -* Defines if the Operating Units are self-balanced and Inter-Operating Unit - clearing account at company level. +* If a company wishes to report Balance Sheet and P&L accounts based on + OU's, they should indicate at company level that the OU's are + self-balanced, and the corresponding Inter-Operating Unit clearing account. + The Chart of Accounts will always be balanced, for each Operating Unit. -* Journal entry with lines in different Operating Units are checked based on - the "self-balanced" set up in OU. +* A company considering Operating Unit as applicable to report only profits + and losses will not need to set the OU's as self-balanced. - At the time of posting the journal entry, the corresponding lines in the - Inter-Operating Unit clearing account are automatically created, making - each OU self-balanced. +* The self-balancing of Operating Unit is ensured at the time of posting a + journal entry. In case that the journal involves posting of items in + separate Operating Units, new journal items will be created, using the + Inter-Operating Unit clearing account, to ensure that each OU is going to + be self-balanced for that journal entry. -* The account financial reports include the option to filter by OU. +* Adds the Operating Unit (OU) to the invoice. A user can choose what OU to + create the invoice for. -* Adds the Operating Unit (OU) to the invoice. +* Adds the Operating Unit (OU) to payments and payment methods. The operating + unit of a payment will be that of the payment method choosen. + +* Implements security rules at OU level to invoices, payments and journal + items. -* Implements security rules in the invoice based on OU. Installation ============ @@ -46,7 +56,9 @@ be self-balanced, and then indicate a self-balancing clearing account. Then set the "Inter-OU Clearing" account in "Inter-Operating Unit clearing account" field. -3. Assign Operating Unit in Accounts. +3. Go to *Accounting / Configuration / Accounting / Journals* and define, for + each Payment Method (journals of type cash or bank), the Operating Unit + that will be used in payments. Usage @@ -63,10 +75,24 @@ Usage self-balanced, then additional move lines will be created so as to make the move self-balanced from OU perspective. +* In the menu *Accounting / Reporting / PDF Reports*, you can indicate the + Operating Units to report on, for the *Trial Balance*, *Balance Sheet*, + *Profit and Loss*, and *Financial Reports*. + + .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/213/9.0 +Known issues / Roadmap +====================== + +* The *General Ledger*, *Aged Partner Balance* reports do not support the + filter by Operating Unit. Basically due to lack of proper hooks in the + standard methods used by these reports, to introduce the ability to filter + by Operating Unit. + + Bug Tracker =========== @@ -87,6 +113,8 @@ Contributors ------------ * Eficent Business and IT Consulting Services S.L. +* Jordi Ballester Alomar +* Aarón Henríquez * Serpent Consulting Services Pvt. Ltd. Maintainer diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index 4d9ce2a0df..5eba7b0890 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -19,13 +19,16 @@ "data": [ "security/account_security.xml", "views/account_move_view.xml", - "views/account_account_view.xml", + "views/account_journal_view.xml", "views/company_view.xml", "views/invoice_view.xml", + "views/account_payment_view.xml", "views/account_invoice_report_view.xml", "views/report_financial.xml", + "views/report_trialbalance.xml", "wizard/account_report_common_view.xml", "wizard/account_financial_report_view.xml", + "wizard/account_report_trial_balance_view.xml", ], "installable": True, } diff --git a/account_operating_unit/models/__init__.py b/account_operating_unit/models/__init__.py index 14ec5df6cf..44e70327a6 100644 --- a/account_operating_unit/models/__init__.py +++ b/account_operating_unit/models/__init__.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import company -from . import account_account +from . import account_journal from . import account_move from . import invoice +from . import account_payment diff --git a/account_operating_unit/models/account_account.py b/account_operating_unit/models/account_account.py deleted file mode 100644 index 94ddc76836..0000000000 --- a/account_operating_unit/models/account_account.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. (www.eficent.com) -# - Jordi Ballester Alomar -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models - - -class AccountAccount(models.Model): - _inherit = "account.account" - - operating_unit_id = fields.Many2one('operating.unit', - 'Default Operating Unit', - default=lambda self: - self.env['res.users']. - operating_unit_default_get(self._uid)) diff --git a/account_operating_unit/models/account_journal.py b/account_operating_unit/models/account_journal.py new file mode 100644 index 0000000000..17e05bed92 --- /dev/null +++ b/account_operating_unit/models/account_journal.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp import api, fields, models, _ +from openerp.exceptions import UserError + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + operating_unit_id = fields.Many2one(comodel_name='operating.unit', + string='Operating Unit', + help="Operating Unit that will be " + "used in payments, when this " + "journal is used.") + + @api.multi + @api.constrains('type') + def _check_ou(self): + for journal in self: + if journal.type in ('bank', 'cash') \ + and journal.company_id.ou_is_self_balanced \ + and not journal.operating_unit_id: + raise UserError(_('Configuration error!\nThe operating unit ' + 'must be indicated in bank journals, ' + 'if it has been defined as self-balanced ' + 'at company level.')) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 66989ac430..16a065579e 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.tools.translate import _ from openerp import api, fields, models diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py new file mode 100644 index 0000000000..8191c6b504 --- /dev/null +++ b/account_operating_unit/models/account_payment.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp import api, fields, models, _ + + +class AccountPayment(models.Model): + _inherit = "account.payment" + + @api.depends('journal_id') + def _compute_operating_unit_id(self): + for payment in self: + if payment.journal_id: + payment.operating_unit_id = payment.journal_id.operating_unit_id + + operating_unit_id = fields.Many2one( + 'operating.unit', string='Operating Unit', + compute='_compute_operating_unit_id', readonly=True, store=True) + + def _get_counterpart_move_line_vals(self, invoice=False): + res = super(AccountPayment, + self)._get_counterpart_move_line_vals(invoice=invoice) + if invoice: + res['operating_unit_id'] = invoice.operating_unit_id.id or False + else: + res['operating_unit_id'] = self.operating_unit_id.id or False + return res + + def _get_liquidity_move_line_vals(self, amount): + res = super(AccountPayment, self)._get_liquidity_move_line_vals(amount) + res['operating_unit_id'] = self.journal_id.operating_unit_id.id or False + return res + + def _get_dst_liquidity_aml_dict_vals(self): + dst_liquidity_aml_dict = { + 'name': _('Transfer from %s') % self.journal_id.name, + 'account_id': + self.destination_journal_id.default_credit_account_id.id, + 'currency_id': self.destination_journal_id.currency_id.id, + 'payment_id': self.id, + 'journal_id': self.destination_journal_id.id, + } + + if self.currency_id != self.company_id.currency_id: + dst_liquidity_aml_dict.update({ + 'currency_id': self.currency_id.id, + 'amount_currency': -self.amount, + }) + + dst_liquidity_aml_dict.update({ + 'operating_unit_id': + self.destination_journal_id.operating_unit_id.id or False}) + return dst_liquidity_aml_dict + + def _get_transfer_debit_aml_dict_vals(self): + transfer_debit_aml_dict = { + 'name': self.name, + 'payment_id': self.id, + 'account_id': self.company_id.transfer_account_id.id, + 'journal_id': self.destination_journal_id.id + } + transfer_debit_aml_dict.update({ + 'operating_unit_id': + self.journal_id.operating_unit_id.id or False + }) + return transfer_debit_aml_dict + + def _create_transfer_entry(self, amount): + """ We need to override the standard method, until proper hooks are + created + """ + aml_obj = self.env['account.move.line'].with_context( + check_move_validity=False) + debit, credit, amount_currency, dummy = aml_obj.with_context( + date=self.payment_date).compute_amount_fields( + amount, self.currency_id, self.company_id.currency_id) + amount_currency = self.destination_journal_id.currency_id \ + and self.currency_id.with_context(date=self.payment_date).compute( + amount, self.destination_journal_id.currency_id) or 0 + + dst_move = self.env['account.move'].create( + self._get_move_vals(self.destination_journal_id)) + + dst_liquidity_aml_dict = self._get_shared_move_line_vals( + debit, credit, amount_currency, dst_move.id) + dst_liquidity_aml_dict.update(self._get_dst_liquidity_aml_dict_vals()) + aml_obj.create(dst_liquidity_aml_dict) + + transfer_debit_aml_dict = self._get_shared_move_line_vals( + credit, debit, 0, dst_move.id) + transfer_debit_aml_dict.update(self._get_transfer_debit_aml_dict_vals()) + transfer_debit_aml = aml_obj.create(transfer_debit_aml_dict) + dst_move.post() + return transfer_debit_aml diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index 8ebf7914f2..19ce8efc00 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models from openerp.tools.translate import _ diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index 4ed7cbcba4..40af796724 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models from openerp.exceptions import ValidationError diff --git a/account_operating_unit/security/account_security.xml b/account_operating_unit/security/account_security.xml index 250fbaaf69..a81c4e2c9a 100644 --- a/account_operating_unit/security/account_security.xml +++ b/account_operating_unit/security/account_security.xml @@ -35,5 +35,17 @@ + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Payments from allowed operating units + + + + + + + diff --git a/account_operating_unit/tests/__init__.py b/account_operating_unit/tests/__init__.py index 57c9e3f0d4..b34bd81caa 100644 --- a/account_operating_unit/tests/__init__.py +++ b/account_operating_unit/tests/__init__.py @@ -7,3 +7,4 @@ from . import test_invoice_operating_unit from . import test_cross_ou_journal_entry from . import test_operating_unit_security +from . import test_payment_operating_unit diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index 59697b520d..d273d999e6 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -12,7 +12,14 @@ def setUp(self): super(TestAccountOperatingUnit, self).setUp() self.res_users_model = self.env['res.users'] self.aml_model = self.env['account.move.line'] + self.invoice_model = self.env['account.invoice'] + self.inv_line_model = self.env['account.invoice.line'] self.account_model = self.env['account.account'] + self.journal_model = self.env['account.journal'] + self.product_model = self.env['product.product'] + self.payment_model = self.env['account.payment'] + self.register_payments_model = self.env['account.register.payments'] + # company self.company = self.env.ref('base.main_company') self.grp_acc_manager = self.env.ref('account.group_account_manager') @@ -28,6 +35,11 @@ def setUp(self): self.product1 = self.env.ref('product.product_product_7') self.product2 = self.env.ref('product.product_product_9') self.product3 = self.env.ref('product.product_product_11') + + # Payment methods + self.payment_method_manual_in = self.env.ref( + "account.account_payment_method_manual_in") + # Create user1 self.user_id =\ self.res_users_model.with_context({'no_reset_password': True}).\ @@ -42,10 +54,10 @@ def setUp(self): 'groups_id': [(6, 0, [self.grp_acc_manager.id])] }) # Create cash - test account - user_type = self.env.ref('account.data_account_type_liquidity') - self.cash_account_id = self.account_model.create({ - 'name': 'Cash - Test', - 'code': 'test_cash', + user_type = self.env.ref('account.data_account_type_current_assets') + self.current_asset_account_id = self.account_model.create({ + 'name': 'Current asset - Test', + 'code': 'test_current_asset', 'user_type_id': user_type.id, 'company_id': self.company.id, }) @@ -74,3 +86,74 @@ def setUp(self): 'operating_unit_ids': [(4, self.b2c.id)], 'groups_id': [(6, 0, [self.grp_acc_manager.id])] }) + + # Create a cash account 1 + user_type = self.env.ref('account.data_account_type_liquidity') + self.cash1_account_id = self.account_model.create({ + 'name': 'Cash 1 - Test', + 'code': 'test_cash_1', + 'user_type_id': user_type.id, + 'company_id': self.company.id, + }) + + # Create a journal for cash account 1, associated to the main + # operating unit + self.cash_journal_ou1 = self.journal_model.create({ + 'name': 'Cash Journal 1 - Test', + 'code': 'test_cash_1', + 'type': 'cash', + 'company_id': self.company.id, + 'default_debit_account_id': self.cash1_account_id.id, + 'default_credit_account_id': self.cash1_account_id.id, + 'operating_unit_id': self.ou1.id + }) + + + # Create a cash account 2 + user_type = self.env.ref('account.data_account_type_liquidity') + self.cash2_account_id = self.account_model.create({ + 'name': 'Cash 2 - Test', + 'code': 'test_cash_2', + 'user_type_id': user_type.id, + 'company_id': self.company.id, + }) + + # Create a journal for cash account 2, associated to the operating + # unit B2B + self.cash2_journal_b2b = self.journal_model.create({ + 'name': 'Cash Journal 2 - Test', + 'code': 'test_cash_2', + 'type': 'cash', + 'company_id': self.company.id, + 'default_debit_account_id': self.cash2_account_id.id, + 'default_credit_account_id': self.cash2_account_id.id, + 'operating_unit_id': self.b2b.id + }) + + def _prepare_invoice(self, operating_unit_id): + line_products = [(self.product1, 1000), + (self.product2, 500), + (self.product3, 800)] + # Prepare invoice lines + lines = [] + acc_type = self.env.ref('account.data_account_type_expenses') + for product, qty in line_products: + line_values = { + 'name': product.name, + 'product_id': product.id, + 'quantity': qty, + 'price_unit': 50, + 'account_id': self.env['account.account']. + search([('user_type_id', '=', acc_type.id)], limit=1).id, + } + lines.append((0, 0, line_values)) + inv_vals = { + 'partner_id': self.partner1.id, + 'account_id': self.partner1.property_account_payable_id.id, + 'operating_unit_id': operating_unit_id, + 'name': "Test Supplier Invoice", + 'reference_type': "none", + 'type': 'in_invoice', + 'invoice_line_ids': lines, + } + return inv_vals \ No newline at end of file diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py index db3689e99d..ab74aefa10 100644 --- a/account_operating_unit/tests/test_cross_ou_journal_entry.py +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -29,14 +29,14 @@ def test_cross_ou_journal_entry(self): lines = [ (0, 0, { 'name': 'Test', - 'account_id': self.cash_account_id.id, + 'account_id': self.current_asset_account_id.id, 'debit': 0, 'credit': 100, 'operating_unit_id': self.b2b.id, }), (0, 0, { 'name': 'Test', - 'account_id': self.cash_account_id.id, + 'account_id': self.current_asset_account_id.id, 'debit': 100, 'credit': 0, 'operating_unit_id': self.b2c.id, @@ -50,7 +50,7 @@ def test_cross_ou_journal_entry(self): # Post journal entries move.post() # Check the balance of the account - self._check_balance(self.cash_account_id.id, acc_type='cash') + self._check_balance(self.current_asset_account_id.id, acc_type='other') clearing_account_id = self.company.inter_ou_clearing_account_id.id self._check_balance(clearing_account_id, acc_type='clearing') @@ -63,7 +63,7 @@ def _check_balance(self, account_id, acc_type='clearing'): domain = [('account_id', '=', account_id), ('operating_unit_id', '=', self.b2b.id)] balance = self._get_balance(domain) - if acc_type == 'cash': + if acc_type == 'other': self.assertEqual(balance, -100, 'Balance is -100 for Operating Unit B2B.') else: @@ -73,7 +73,7 @@ def _check_balance(self, account_id, acc_type='clearing'): domain = [('account_id', '=', account_id), ('operating_unit_id', '=', self.b2c.id)] balance = self._get_balance(domain) - if acc_type == 'cash': + if acc_type == 'other': self.assertEqual(balance, 100.0, 'Balance is 100 for Operating Unit B2C.') else: diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index 8b8069d23e..7c5afe4b40 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -13,38 +13,10 @@ def test_create_invoice_validate(self): Test that when an invoice is created, the operating unit is passed to the accounting journal items. """ - line_products = [(self.product1, 1000), - (self.product2, 500), - (self.product3, 800)] - self.invoice_model = self.env['account.invoice'] - self.journal_model = self.env['account.journal'] - self.product_model = self.env['product.product'] - self.inv_line_model = self.env['account.invoice.line'] - # Prepare invoice lines - lines = [] - acc_type = self.env.ref('account.data_account_type_expenses') - for product, qty in line_products: - line_values = { - 'name': product.name, - 'product_id': product.id, - 'quantity': qty, - 'price_unit': 50, - 'account_id': self.env['account.account']. - search([('user_type_id', '=', acc_type.id)], limit=1).id, - } - lines.append((0, 0, line_values)) - inv_vals = { - 'partner_id': self.partner1.id, - 'account_id': self.partner1.property_account_payable_id.id, - 'operating_unit_id': self.b2b.id, - 'name': "Test Supplier Invoice", - 'reference_type': "none", - 'type': 'in_invoice', - 'invoice_line_ids': lines, - } # Create invoice self.invoice =\ - self.invoice_model.sudo(self.user_id.id).create(inv_vals) + self.invoice_model.sudo(self.user_id.id).create( + self._prepare_invoice(self.b2b.id)) # Validate the invoice self.invoice.sudo(self.user_id.id).signal_workflow('invoice_open') # Check Operating Units in journal entries diff --git a/account_operating_unit/tests/test_payment_operating_unit.py b/account_operating_unit/tests/test_payment_operating_unit.py new file mode 100644 index 0000000000..a3fe8f68be --- /dev/null +++ b/account_operating_unit/tests/test_payment_operating_unit.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar +# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from openerp.addons.account_operating_unit.tests import\ + test_account_operating_unit as test_ou +import time + + +class TestInvoiceOperatingUnit(test_ou.TestAccountOperatingUnit): + + def test_payment_from_invoice(self): + """Create and invoice and a subsquent payment, in another OU""" + + # Create invoice for B2B operating unit + self.invoice = self.invoice_model.sudo(self.user_id.id).create( + self._prepare_invoice(self.b2b.id)) + # Validate the invoice + self.invoice.sudo(self.user_id.id).signal_workflow('invoice_open') + + # Pay the invoice using a cash journal associated to the main company + ctx = {'active_model': 'account.invoice', 'active_ids': [ + self.invoice.id]} + register_payments = \ + self.register_payments_model.with_context(ctx).create({ + 'payment_date': time.strftime('%Y') + '-07-15', + 'journal_id': self.cash_journal_ou1.id, + 'payment_method_id': self.payment_method_manual_in.id + }) + + register_payments.create_payment() + payment = self.payment_model.search([], order="id desc", limit=1) + + self.assertAlmostEquals(payment.amount, 115000) + self.assertEqual(payment.state, 'posted') + self.assertEqual(self.invoice.state, 'paid') diff --git a/account_operating_unit/views/account_account_view.xml b/account_operating_unit/views/account_account_view.xml deleted file mode 100644 index 048404dc6a..0000000000 --- a/account_operating_unit/views/account_account_view.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - account.account.form - account.account - - - - - - - - - - diff --git a/account_operating_unit/views/account_invoice_report_view.xml b/account_operating_unit/views/account_invoice_report_view.xml index 1d2d35a934..c255de3639 100644 --- a/account_operating_unit/views/account_invoice_report_view.xml +++ b/account_operating_unit/views/account_invoice_report_view.xml @@ -9,7 +9,8 @@ ref="account.view_account_invoice_report_search"/> - + + + + + + account.journal.form + account.journal + + + + + + + + + + diff --git a/account_operating_unit/views/account_move_view.xml b/account_operating_unit/views/account_move_view.xml index fa30ebab9f..ede94ad499 100644 --- a/account_operating_unit/views/account_move_view.xml +++ b/account_operating_unit/views/account_move_view.xml @@ -8,7 +8,9 @@ - + @@ -19,7 +21,9 @@ - + @@ -30,7 +34,9 @@ - + @@ -59,7 +65,9 @@ - + diff --git a/account_operating_unit/views/account_payment_view.xml b/account_operating_unit/views/account_payment_view.xml new file mode 100644 index 0000000000..309a3f0d69 --- /dev/null +++ b/account_operating_unit/views/account_payment_view.xml @@ -0,0 +1,61 @@ + + + + + + account.payment.tree + account.payment + + + + + + + + + + account.supplier.payment.tree + account.payment + + + + + + + + + + account.payment.search + account.payment + + + + + + + + + + + + + + account.payment.form + account.payment + + + + + + + + + + diff --git a/account_operating_unit/views/invoice_view.xml b/account_operating_unit/views/invoice_view.xml index a314803b73..e65edb4520 100644 --- a/account_operating_unit/views/invoice_view.xml +++ b/account_operating_unit/views/invoice_view.xml @@ -8,7 +8,9 @@ - + @@ -35,7 +37,9 @@ - + @@ -46,7 +50,9 @@ - + diff --git a/account_operating_unit/views/report_agedpartnerbalance.xml b/account_operating_unit/views/report_agedpartnerbalance.xml new file mode 100644 index 0000000000..f2f71427b3 --- /dev/null +++ b/account_operating_unit/views/report_agedpartnerbalance.xml @@ -0,0 +1,12 @@ + + + + diff --git a/account_operating_unit/views/report_trialbalance.xml b/account_operating_unit/views/report_trialbalance.xml new file mode 100644 index 0000000000..963a68ee50 --- /dev/null +++ b/account_operating_unit/views/report_trialbalance.xml @@ -0,0 +1,12 @@ + + + + diff --git a/account_operating_unit/wizard/__init__.py b/account_operating_unit/wizard/__init__.py index db7122592e..a161bc0f29 100644 --- a/account_operating_unit/wizard/__init__.py +++ b/account_operating_unit/wizard/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import account_report_common from . import account_financial_report +from . import account_report_trial_balance diff --git a/account_operating_unit/wizard/account_financial_report_view.xml b/account_operating_unit/wizard/account_financial_report_view.xml index f0377355e7..21c0124fc0 100644 --- a/account_operating_unit/wizard/account_financial_report_view.xml +++ b/account_operating_unit/wizard/account_financial_report_view.xml @@ -8,7 +8,11 @@ - + diff --git a/account_operating_unit/wizard/account_report_common.py b/account_operating_unit/wizard/account_report_common.py index 6c3cbca114..1d5f710873 100644 --- a/account_operating_unit/wizard/account_report_common.py +++ b/account_operating_unit/wizard/account_report_common.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/wizard/account_report_common_view.xml b/account_operating_unit/wizard/account_report_common_view.xml index c3f181fcd9..7c552974d0 100644 --- a/account_operating_unit/wizard/account_report_common_view.xml +++ b/account_operating_unit/wizard/account_report_common_view.xml @@ -7,13 +7,10 @@ account.common.report - - - - - - - + + + diff --git a/account_operating_unit/wizard/account_report_trial_balance.py b/account_operating_unit/wizard/account_report_trial_balance.py new file mode 100644 index 0000000000..72810baed4 --- /dev/null +++ b/account_operating_unit/wizard/account_report_trial_balance.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from openerp import fields, models + + +class AccountBalanceReport(models.TransientModel): + _inherit = "account.balance.report" + + operating_unit_ids = fields.Many2many( + 'operating.unit', 'account_balance_report_operating_unit_rel', + 'account_id', 'operating_unit_id', string='Operating Units', + required=False, + default=[]) + + def _build_contexts(self, data): + result = super(AccountBalanceReport, self)._build_contexts(data) + data2 = {} + data2['form'] = self.read(['operating_unit_ids'])[0] + result['operating_unit_ids'] = 'operating_unit_ids' in data2['form'] \ + and data2['form']['operating_unit_ids'] \ + or False + return result + + def _print_report(self, data): + operating_units = ', '.join([ou.name for ou in self.operating_unit_ids]) + data['form'].update({'operating_units': operating_units}) + return super(AccountBalanceReport, self)._print_report(data) \ No newline at end of file diff --git a/account_operating_unit/wizard/account_report_trial_balance_view.xml b/account_operating_unit/wizard/account_report_trial_balance_view.xml new file mode 100644 index 0000000000..a525cb3782 --- /dev/null +++ b/account_operating_unit/wizard/account_report_trial_balance_view.xml @@ -0,0 +1,19 @@ + + + + + + Trial Balance + account.balance.report + + + + + + + + + + + From 1dc8235cdd1508190ba546e49b660ff503cc8429 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 14 Sep 2016 17:54:22 +0200 Subject: [PATCH 024/130] [IMP] simplify headers --- account_operating_unit/__init__.py | 4 +--- account_operating_unit/__openerp__.py | 4 +--- account_operating_unit/report/__init__.py | 6 ++---- account_operating_unit/report/account_invoice_report.py | 6 +++--- account_operating_unit/tests/__init__.py | 3 +-- account_operating_unit/tests/test_account_operating_unit.py | 3 +-- account_operating_unit/tests/test_cross_ou_journal_entry.py | 3 +-- account_operating_unit/tests/test_invoice_operating_unit.py | 3 +-- .../tests/test_operating_unit_security.py | 3 +-- account_operating_unit/tests/test_payment_operating_unit.py | 3 +-- account_operating_unit/wizard/account_financial_report.py | 3 +-- .../wizard/account_report_trial_balance.py | 1 - 12 files changed, 14 insertions(+), 28 deletions(-) diff --git a/account_operating_unit/__init__.py b/account_operating_unit/__init__.py index 0a28cfa289..f7e9ee51d6 100644 --- a/account_operating_unit/__init__.py +++ b/account_operating_unit/__init__.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). - from . import models from . import wizard from . import report diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index 5eba7b0890..c1034794f2 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). - { "name": 'Accounting with Operating Units', "summary": "Introduces Operating Unit fields in invoices and " diff --git a/account_operating_unit/report/__init__.py b/account_operating_unit/report/__init__.py index 3b9390b5a4..a02d2bc388 100644 --- a/account_operating_unit/report/__init__.py +++ b/account_operating_unit/report/__init__.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import account_invoice_report diff --git a/account_operating_unit/report/account_invoice_report.py b/account_operating_unit/report/account_invoice_report.py index 2f81b8734a..453d5be9d6 100644 --- a/account_operating_unit/report/account_invoice_report.py +++ b/account_operating_unit/report/account_invoice_report.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Eficent Business and IT Consulting Services S.L. -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). - +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/tests/__init__.py b/account_operating_unit/tests/__init__.py index b34bd81caa..7a03d16fcc 100644 --- a/account_operating_unit/tests/__init__.py +++ b/account_operating_unit/tests/__init__.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit from . import test_invoice_operating_unit diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index d273d999e6..0a13dc8393 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account.tests import account_test_classes diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py index ab74aefa10..c9aabfddec 100644 --- a/account_operating_unit/tests/test_cross_ou_journal_entry.py +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index 7c5afe4b40..592ae3731e 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py index a84a2774f8..598b09f95f 100644 --- a/account_operating_unit/tests/test_operating_unit_security.py +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_payment_operating_unit.py b/account_operating_unit/tests/test_payment_operating_unit.py index a3fe8f68be..4d61459c32 100644 --- a/account_operating_unit/tests/test_payment_operating_unit.py +++ b/account_operating_unit/tests/test_payment_operating_unit.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ test_account_operating_unit as test_ou diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py index f0273f0a26..afea246f7b 100644 --- a/account_operating_unit/wizard/account_financial_report.py +++ b/account_operating_unit/wizard/account_financial_report.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Eficent Business and IT Consulting Services S.L. -# - Jordi Ballester Alomar -# © 2016 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/wizard/account_report_trial_balance.py b/account_operating_unit/wizard/account_report_trial_balance.py index 72810baed4..28b919a9ce 100644 --- a/account_operating_unit/wizard/account_report_trial_balance.py +++ b/account_operating_unit/wizard/account_report_trial_balance.py @@ -2,7 +2,6 @@ # © 2016 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). - from openerp import fields, models From 16d9d9407f8d89a671b578bc0ba28f18be577e38 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 14 Sep 2016 17:56:27 +0200 Subject: [PATCH 025/130] [IMP] update readme --- account_operating_unit/README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index fe8e998da5..26cacce12f 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -66,6 +66,9 @@ Usage * Add the Operating Unit to invoices. +* Report invoices by Operating Unit in *Accounting / Reporting* + *Business Intelligence / Invoices* + * Add the Default Operating Unit to account move. Then all move lines will by default adopt this Operating Unit. From c3b0bbe55bf84f03268431202c91318b6d86093c Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 14 Sep 2016 18:26:30 +0200 Subject: [PATCH 026/130] [FIX] PEP8 issues --- account_operating_unit/models/account_payment.py | 9 ++++++--- .../tests/test_account_operating_unit.py | 6 +++--- .../wizard/account_report_trial_balance.py | 8 +++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py index 8191c6b504..65084197ec 100644 --- a/account_operating_unit/models/account_payment.py +++ b/account_operating_unit/models/account_payment.py @@ -12,7 +12,8 @@ class AccountPayment(models.Model): def _compute_operating_unit_id(self): for payment in self: if payment.journal_id: - payment.operating_unit_id = payment.journal_id.operating_unit_id + payment.operating_unit_id = \ + payment.journal_id.operating_unit_id operating_unit_id = fields.Many2one( 'operating.unit', string='Operating Unit', @@ -29,7 +30,8 @@ def _get_counterpart_move_line_vals(self, invoice=False): def _get_liquidity_move_line_vals(self, amount): res = super(AccountPayment, self)._get_liquidity_move_line_vals(amount) - res['operating_unit_id'] = self.journal_id.operating_unit_id.id or False + res['operating_unit_id'] = self.journal_id.operating_unit_id.id \ + or False return res def _get_dst_liquidity_aml_dict_vals(self): @@ -89,7 +91,8 @@ def _create_transfer_entry(self, amount): transfer_debit_aml_dict = self._get_shared_move_line_vals( credit, debit, 0, dst_move.id) - transfer_debit_aml_dict.update(self._get_transfer_debit_aml_dict_vals()) + transfer_debit_aml_dict.update( + self._get_transfer_debit_aml_dict_vals()) transfer_debit_aml = aml_obj.create(transfer_debit_aml_dict) dst_move.post() return transfer_debit_aml diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index 0a13dc8393..2a3fc86379 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -142,8 +142,8 @@ def _prepare_invoice(self, operating_unit_id): 'product_id': product.id, 'quantity': qty, 'price_unit': 50, - 'account_id': self.env['account.account']. - search([('user_type_id', '=', acc_type.id)], limit=1).id, + 'account_id': self.env['account.account'].search( + [('user_type_id', '=', acc_type.id)], limit=1).id } lines.append((0, 0, line_values)) inv_vals = { @@ -155,4 +155,4 @@ def _prepare_invoice(self, operating_unit_id): 'type': 'in_invoice', 'invoice_line_ids': lines, } - return inv_vals \ No newline at end of file + return inv_vals diff --git a/account_operating_unit/wizard/account_report_trial_balance.py b/account_operating_unit/wizard/account_report_trial_balance.py index 28b919a9ce..9d33741e07 100644 --- a/account_operating_unit/wizard/account_report_trial_balance.py +++ b/account_operating_unit/wizard/account_report_trial_balance.py @@ -18,12 +18,14 @@ def _build_contexts(self, data): result = super(AccountBalanceReport, self)._build_contexts(data) data2 = {} data2['form'] = self.read(['operating_unit_ids'])[0] - result['operating_unit_ids'] = 'operating_unit_ids' in data2['form'] \ - and data2['form']['operating_unit_ids'] \ + result['operating_unit_ids'] = 'operating_unit_ids' \ + in data2['form'] and \ + data2['form']['operating_unit_ids'] \ or False return result def _print_report(self, data): - operating_units = ', '.join([ou.name for ou in self.operating_unit_ids]) + operating_units = ', '.join([ou.name for ou in + self.operating_unit_ids]) data['form'].update({'operating_units': operating_units}) return super(AccountBalanceReport, self)._print_report(data) \ No newline at end of file From 0989375b6dde27f3bd71149b9abb8948ec07cd2d Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 16 Sep 2016 15:54:28 +0200 Subject: [PATCH 027/130] [IMP] add security for account journals --- .../security/account_security.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/account_operating_unit/security/account_security.xml b/account_operating_unit/security/account_security.xml index a81c4e2c9a..4318ac1623 100644 --- a/account_operating_unit/security/account_security.xml +++ b/account_operating_unit/security/account_security.xml @@ -2,6 +2,19 @@ + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Journals from allowed operating units + + + + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] From a248c0e5bc7cbbb4a300248e01a41a81e7ea13f5 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 16 Sep 2016 16:31:48 +0200 Subject: [PATCH 028/130] [IMP] add security by OU on the account invoice report --- .../security/account_security.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/account_operating_unit/security/account_security.xml b/account_operating_unit/security/account_security.xml index 4318ac1623..4388a0077c 100644 --- a/account_operating_unit/security/account_security.xml +++ b/account_operating_unit/security/account_security.xml @@ -60,5 +60,18 @@ + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Invoice Report from allowed operating units + + + + + + + From cc78097055ad606d43f505e928458f50187d78a6 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 28 Sep 2016 12:10:18 +0200 Subject: [PATCH 029/130] [FIX] flake8 --- account_operating_unit/tests/test_account_operating_unit.py | 1 - account_operating_unit/wizard/account_report_trial_balance.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index 2a3fc86379..b74a5b6f6b 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -107,7 +107,6 @@ def setUp(self): 'operating_unit_id': self.ou1.id }) - # Create a cash account 2 user_type = self.env.ref('account.data_account_type_liquidity') self.cash2_account_id = self.account_model.create({ diff --git a/account_operating_unit/wizard/account_report_trial_balance.py b/account_operating_unit/wizard/account_report_trial_balance.py index 9d33741e07..8c77904a15 100644 --- a/account_operating_unit/wizard/account_report_trial_balance.py +++ b/account_operating_unit/wizard/account_report_trial_balance.py @@ -28,4 +28,4 @@ def _print_report(self, data): operating_units = ', '.join([ou.name for ou in self.operating_unit_ids]) data['form'].update({'operating_units': operating_units}) - return super(AccountBalanceReport, self)._print_report(data) \ No newline at end of file + return super(AccountBalanceReport, self)._print_report(data) From 3ac88f581b4abc87c33761d9de54beaa9d66516b Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 16:04:30 +0200 Subject: [PATCH 030/130] [MIG] Make modules uninstallable --- account_operating_unit/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__openerp__.py index c1034794f2..98c7aaf7ba 100644 --- a/account_operating_unit/__openerp__.py +++ b/account_operating_unit/__openerp__.py @@ -28,5 +28,5 @@ "wizard/account_financial_report_view.xml", "wizard/account_report_trial_balance_view.xml", ], - "installable": True, + 'installable': False, } From 9ccd8d8fc2f09ffef7318c58c4938fd11e635f46 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 16:04:31 +0200 Subject: [PATCH 031/130] [MIG] Rename manifest files --- account_operating_unit/{__openerp__.py => __manifest__.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename account_operating_unit/{__openerp__.py => __manifest__.py} (100%) diff --git a/account_operating_unit/__openerp__.py b/account_operating_unit/__manifest__.py similarity index 100% rename from account_operating_unit/__openerp__.py rename to account_operating_unit/__manifest__.py From f79e2216ab5aa115711e77168b069cf609ec66f3 Mon Sep 17 00:00:00 2001 From: lreficent Date: Thu, 26 Jan 2017 14:35:12 +0100 Subject: [PATCH 032/130] [MIG] account_operating_unit to v10.0 --- account_operating_unit/__init__.py | 2 +- account_operating_unit/__manifest__.py | 10 +- account_operating_unit/models/__init__.py | 2 +- .../models/account_journal.py | 2 +- account_operating_unit/models/account_move.py | 2 +- .../models/account_payment.py | 2 +- account_operating_unit/models/company.py | 2 +- account_operating_unit/models/invoice.py | 2 +- account_operating_unit/report/__init__.py | 2 +- .../report/account_invoice_report.py | 2 +- .../security/account_security.xml | 133 +++++++++--------- account_operating_unit/tests/__init__.py | 2 +- .../tests/test_account_operating_unit.py | 2 +- .../tests/test_cross_ou_journal_entry.py | 2 +- .../tests/test_invoice_operating_unit.py | 2 +- .../tests/test_operating_unit_security.py | 2 +- .../tests/test_payment_operating_unit.py | 2 +- .../views/account_invoice_report_view.xml | 6 +- .../views/account_journal_view.xml | 30 ++-- .../views/account_move_view.xml | 132 +++++++++-------- .../views/account_payment_view.xml | 98 +++++++------ account_operating_unit/views/company_view.xml | 28 ++-- account_operating_unit/views/invoice_view.xml | 102 +++++++------- .../views/report_agedpartnerbalance.xml | 2 + .../views/report_financial.xml | 2 + .../views/report_trialbalance.xml | 2 + account_operating_unit/wizard/__init__.py | 2 +- .../wizard/account_financial_report.py | 2 +- .../wizard/account_financial_report_view.xml | 6 +- .../wizard/account_report_common.py | 2 +- .../wizard/account_report_common_view.xml | 6 +- .../wizard/account_report_trial_balance.py | 2 +- 32 files changed, 291 insertions(+), 304 deletions(-) diff --git a/account_operating_unit/__init__.py b/account_operating_unit/__init__.py index f7e9ee51d6..a647cd034c 100644 --- a/account_operating_unit/__init__.py +++ b/account_operating_unit/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/account_operating_unit/__manifest__.py b/account_operating_unit/__manifest__.py index 98c7aaf7ba..2c6b0053f0 100644 --- a/account_operating_unit/__manifest__.py +++ b/account_operating_unit/__manifest__.py @@ -1,16 +1,16 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": 'Accounting with Operating Units', "summary": "Introduces Operating Unit fields in invoices and " "Accounting Entries with clearing account", - "version": "9.0.1.0.0", - "author": "Eficent Business and IT Consulting Services S.L., " + "version": "10.0.1.0.0", + "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", - "website": "http://www.eficent.com", + "website": "https://github.com/OCA/operating-unit", "category": "Accounting & Finance", "depends": ['account', 'operating_unit'], "license": "LGPL-3", @@ -28,5 +28,5 @@ "wizard/account_financial_report_view.xml", "wizard/account_report_trial_balance_view.xml", ], - 'installable': False, + 'installable': True, } diff --git a/account_operating_unit/models/__init__.py b/account_operating_unit/models/__init__.py index 44e70327a6..f1237de449 100644 --- a/account_operating_unit/models/__init__.py +++ b/account_operating_unit/models/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import company diff --git a/account_operating_unit/models/account_journal.py b/account_operating_unit/models/account_journal.py index 17e05bed92..474473033c 100644 --- a/account_operating_unit/models/account_journal.py +++ b/account_operating_unit/models/account_journal.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models, _ diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 16a065579e..53b553785f 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.tools.translate import _ diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py index 65084197ec..a6517b8534 100644 --- a/account_operating_unit/models/account_payment.py +++ b/account_operating_unit/models/account_payment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models, _ diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index 19ce8efc00..248d9eb0ec 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index 40af796724..f442b24ff8 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models diff --git a/account_operating_unit/report/__init__.py b/account_operating_unit/report/__init__.py index a02d2bc388..5be7018e74 100644 --- a/account_operating_unit/report/__init__.py +++ b/account_operating_unit/report/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import account_invoice_report diff --git a/account_operating_unit/report/account_invoice_report.py b/account_operating_unit/report/account_invoice_report.py index 453d5be9d6..24b35d43d9 100644 --- a/account_operating_unit/report/account_invoice_report.py +++ b/account_operating_unit/report/account_invoice_report.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/security/account_security.xml b/account_operating_unit/security/account_security.xml index 4388a0077c..35bff1b1d4 100644 --- a/account_operating_unit/security/account_security.xml +++ b/account_operating_unit/security/account_security.xml @@ -1,77 +1,74 @@ - - + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Journals from allowed operating units + + + + + + - - - ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Journals from allowed operating units - - - - - - + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Invoices from allowed operating units + + + + + + - - - ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Invoices from allowed operating units - - - - - - + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Invoice lines from allowed operating units + + + + + + - - - ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Invoice lines from allowed operating units - - - - - - + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Move lines from allowed operating units + + + + + + - - - ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Move lines from allowed operating units - - - - - - + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Payments from allowed operating units + + + + + + - - - ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Payments from allowed operating units - - - - - - + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Invoice Report from allowed operating units + + + + + + - - - ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Invoice Report from allowed operating units - - - - - - - - - + diff --git a/account_operating_unit/tests/__init__.py b/account_operating_unit/tests/__init__.py index 7a03d16fcc..9ef001663c 100644 --- a/account_operating_unit/tests/__init__.py +++ b/account_operating_unit/tests/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index b74a5b6f6b..0c429cc2d8 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account.tests import account_test_classes diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py index c9aabfddec..566cbab64c 100644 --- a/account_operating_unit/tests/test_cross_ou_journal_entry.py +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index 592ae3731e..1556ed69fa 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py index 598b09f95f..17cd77b0cc 100644 --- a/account_operating_unit/tests/test_operating_unit_security.py +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_payment_operating_unit.py b/account_operating_unit/tests/test_payment_operating_unit.py index 4d61459c32..913f30decd 100644 --- a/account_operating_unit/tests/test_payment_operating_unit.py +++ b/account_operating_unit/tests/test_payment_operating_unit.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp.addons.account_operating_unit.tests import\ diff --git a/account_operating_unit/views/account_invoice_report_view.xml b/account_operating_unit/views/account_invoice_report_view.xml index c255de3639..8a0b22097b 100644 --- a/account_operating_unit/views/account_invoice_report_view.xml +++ b/account_operating_unit/views/account_invoice_report_view.xml @@ -1,6 +1,5 @@ - - + account.invoice.report.search @@ -21,5 +20,4 @@ - - + diff --git a/account_operating_unit/views/account_journal_view.xml b/account_operating_unit/views/account_journal_view.xml index fe90d8c58d..3893eff179 100644 --- a/account_operating_unit/views/account_journal_view.xml +++ b/account_operating_unit/views/account_journal_view.xml @@ -1,20 +1,18 @@ - - + - - account.journal.form - account.journal - - - - - + + account.journal.form + account.journal + + + + - + + - - + diff --git a/account_operating_unit/views/account_move_view.xml b/account_operating_unit/views/account_move_view.xml index ede94ad499..d881f0408a 100644 --- a/account_operating_unit/views/account_move_view.xml +++ b/account_operating_unit/views/account_move_view.xml @@ -1,76 +1,74 @@ - - + - - account.move.line.form - account.move.line - - - - - - - + + account.move.line.form + account.move.line + + + + + + + - - account.move.line.form2 - account.move.line - - - - - - - + + account.move.line.form2 + account.move.line + + + + + + + - - account.move.line.tree - account.move.line - - - - - - - + + account.move.line.tree + account.move.line + + + + + + + - - Journal Items - account.move.line - - - - - - - - + + Journal Items + account.move.line + + + + + + + + - - account.move.form - account.move - - - - - - - - + + account.move.form + account.move + + + + - + + + + + - - + diff --git a/account_operating_unit/views/account_payment_view.xml b/account_operating_unit/views/account_payment_view.xml index 309a3f0d69..ea96dd1ef5 100644 --- a/account_operating_unit/views/account_payment_view.xml +++ b/account_operating_unit/views/account_payment_view.xml @@ -1,61 +1,59 @@ - - + - - account.payment.tree - account.payment - - - - - + + account.payment.tree + account.payment + + + + - + + - - account.supplier.payment.tree - account.payment - - - - - + + account.supplier.payment.tree + account.payment + + + + - + + - - account.payment.search - account.payment - - - - - - - - + + account.payment.search + account.payment + + + + - + + + + + - - account.payment.form - account.payment - - - - - + + account.payment.form + account.payment + + + + - + + - - + diff --git a/account_operating_unit/views/company_view.xml b/account_operating_unit/views/company_view.xml index b51e24f697..a4fc0bbaf1 100644 --- a/account_operating_unit/views/company_view.xml +++ b/account_operating_unit/views/company_view.xml @@ -1,18 +1,16 @@ - - + - - res.company.form - res.company - - - - - - - - + + res.company.form + res.company + + + + + + + + - - + diff --git a/account_operating_unit/views/invoice_view.xml b/account_operating_unit/views/invoice_view.xml index e65edb4520..5cec627aa2 100644 --- a/account_operating_unit/views/invoice_view.xml +++ b/account_operating_unit/views/invoice_view.xml @@ -1,61 +1,59 @@ - - + - - account.invoice.tree - account.invoice - - - - - - - + + account.invoice.tree + account.invoice + + + + + + + - - account.invoice.select - account.invoice - - - - - - - - + + account.invoice.select + account.invoice + + + + - + + + + + - - account.invoice.supplier.form - account.invoice - - - - - + + account.invoice.supplier.form + account.invoice + + + + - + + - - account.invoice.form - account.invoice - - - - - + + account.invoice.form + account.invoice + + + + - + + - - + diff --git a/account_operating_unit/views/report_agedpartnerbalance.xml b/account_operating_unit/views/report_agedpartnerbalance.xml index f2f71427b3..d8c6eced3d 100644 --- a/account_operating_unit/views/report_agedpartnerbalance.xml +++ b/account_operating_unit/views/report_agedpartnerbalance.xml @@ -1,5 +1,6 @@ + + diff --git a/account_operating_unit/views/report_financial.xml b/account_operating_unit/views/report_financial.xml index 9dabeb86a2..13221c85f1 100644 --- a/account_operating_unit/views/report_financial.xml +++ b/account_operating_unit/views/report_financial.xml @@ -1,5 +1,6 @@ + + diff --git a/account_operating_unit/views/report_trialbalance.xml b/account_operating_unit/views/report_trialbalance.xml index 963a68ee50..e7891c537e 100644 --- a/account_operating_unit/views/report_trialbalance.xml +++ b/account_operating_unit/views/report_trialbalance.xml @@ -1,5 +1,6 @@ + + diff --git a/account_operating_unit/wizard/__init__.py b/account_operating_unit/wizard/__init__.py index a161bc0f29..39014534b2 100644 --- a/account_operating_unit/wizard/__init__.py +++ b/account_operating_unit/wizard/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import account_report_common diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py index afea246f7b..cf0cec4ede 100644 --- a/account_operating_unit/wizard/account_financial_report.py +++ b/account_operating_unit/wizard/account_financial_report.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/wizard/account_financial_report_view.xml b/account_operating_unit/wizard/account_financial_report_view.xml index 21c0124fc0..5fca1c3ff1 100644 --- a/account_operating_unit/wizard/account_financial_report_view.xml +++ b/account_operating_unit/wizard/account_financial_report_view.xml @@ -1,6 +1,5 @@ - - + Accounting Report @@ -19,5 +18,4 @@ - - + diff --git a/account_operating_unit/wizard/account_report_common.py b/account_operating_unit/wizard/account_report_common.py index 1d5f710873..e345eeb640 100644 --- a/account_operating_unit/wizard/account_report_common.py +++ b/account_operating_unit/wizard/account_report_common.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models diff --git a/account_operating_unit/wizard/account_report_common_view.xml b/account_operating_unit/wizard/account_report_common_view.xml index 7c552974d0..93122ae8ba 100644 --- a/account_operating_unit/wizard/account_report_common_view.xml +++ b/account_operating_unit/wizard/account_report_common_view.xml @@ -1,6 +1,5 @@ - - + Common Report @@ -14,5 +13,4 @@ - - + diff --git a/account_operating_unit/wizard/account_report_trial_balance.py b/account_operating_unit/wizard/account_report_trial_balance.py index 8c77904a15..f38d759c60 100644 --- a/account_operating_unit/wizard/account_report_trial_balance.py +++ b/account_operating_unit/wizard/account_report_trial_balance.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models From 59ff236efce6e4a5954e2bf85a0b912726e49d4b Mon Sep 17 00:00:00 2001 From: ahenriquez Date: Thu, 26 Jan 2017 18:22:22 +0100 Subject: [PATCH 033/130] [FIX] Company view --- account_operating_unit/README.rst | 4 ++-- account_operating_unit/views/company_view.xml | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 26cacce12f..4e802b1e8e 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -30,7 +30,7 @@ Units (OU's). create the invoice for. * Adds the Operating Unit (OU) to payments and payment methods. The operating - unit of a payment will be that of the payment method choosen. + unit of a payment will be that of the payment method chosen. * Implements security rules at OU level to invoices, payments and journal items. @@ -85,7 +85,7 @@ Usage .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/213/9.0 + :target: https://runbot.odoo-community.org/runbot/213/10.0 Known issues / Roadmap ====================== diff --git a/account_operating_unit/views/company_view.xml b/account_operating_unit/views/company_view.xml index a4fc0bbaf1..f216939f1d 100644 --- a/account_operating_unit/views/company_view.xml +++ b/account_operating_unit/views/company_view.xml @@ -6,10 +6,12 @@ res.company - - - - + + + + + + From b433caeb5bfcf3a6b65256810a48d0b59664a688 Mon Sep 17 00:00:00 2001 From: ahenriquez Date: Fri, 27 Jan 2017 10:25:21 +0100 Subject: [PATCH 034/130] [FIX] Test remove workflow --- account_operating_unit/tests/test_account_operating_unit.py | 4 ++-- account_operating_unit/tests/test_invoice_operating_unit.py | 2 +- account_operating_unit/tests/test_payment_operating_unit.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index 0c429cc2d8..e73ac94d56 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -2,10 +2,10 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp.addons.account.tests import account_test_classes +from odoo.addons.account.tests.account_test_classes import AccountingTestCase -class TestAccountOperatingUnit(account_test_classes.AccountingTestCase): +class TestAccountOperatingUnit(AccountingTestCase): def setUp(self): super(TestAccountOperatingUnit, self).setUp() diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index 1556ed69fa..b7f7a3b10a 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -17,7 +17,7 @@ def test_create_invoice_validate(self): self.invoice_model.sudo(self.user_id.id).create( self._prepare_invoice(self.b2b.id)) # Validate the invoice - self.invoice.sudo(self.user_id.id).signal_workflow('invoice_open') + self.invoice.sudo(self.user_id.id).action_invoice_open() # Check Operating Units in journal entries all_op_units = all(move_line.operating_unit_id.id == self.b2b.id for move_line in self.invoice.move_id.line_ids) diff --git a/account_operating_unit/tests/test_payment_operating_unit.py b/account_operating_unit/tests/test_payment_operating_unit.py index 913f30decd..7f0d65bda5 100644 --- a/account_operating_unit/tests/test_payment_operating_unit.py +++ b/account_operating_unit/tests/test_payment_operating_unit.py @@ -16,7 +16,7 @@ def test_payment_from_invoice(self): self.invoice = self.invoice_model.sudo(self.user_id.id).create( self._prepare_invoice(self.b2b.id)) # Validate the invoice - self.invoice.sudo(self.user_id.id).signal_workflow('invoice_open') + self.invoice.sudo(self.user_id.id).action_invoice_open() # Pay the invoice using a cash journal associated to the main company ctx = {'active_model': 'account.invoice', 'active_ids': [ From e305b7354713c80a1bd04e70770d94683574e2ed Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Mon, 30 Jan 2017 11:44:07 +0100 Subject: [PATCH 035/130] [10.0][account_operating_unit]Add support for cash basis. Migrate to v10 nomenclature (#55) * Add support for cash basis. Migrate to v10 nomenclature * Remove apply_taxes from the create method, as in v10 this parameter is not accepted in the created method --- account_operating_unit/models/account_journal.py | 4 ++-- account_operating_unit/models/account_move.py | 9 +++++---- account_operating_unit/models/account_payment.py | 2 +- account_operating_unit/models/company.py | 6 +++--- account_operating_unit/models/invoice.py | 6 +++--- account_operating_unit/report/account_invoice_report.py | 2 +- .../tests/test_payment_operating_unit.py | 2 +- .../wizard/account_financial_report.py | 2 +- account_operating_unit/wizard/account_report_common.py | 2 +- .../wizard/account_report_trial_balance.py | 2 +- 10 files changed, 19 insertions(+), 18 deletions(-) diff --git a/account_operating_unit/models/account_journal.py b/account_operating_unit/models/account_journal.py index 474473033c..aac87cb468 100644 --- a/account_operating_unit/models/account_journal.py +++ b/account_operating_unit/models/account_journal.py @@ -2,8 +2,8 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models, _ -from openerp.exceptions import UserError +from odoo import api, fields, models, _ +from odoo.exceptions import UserError class AccountJournal(models.Model): diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 53b553785f..8c8680fde1 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -2,9 +2,9 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp.tools.translate import _ -from openerp import api, fields, models -from openerp.exceptions import UserError +from odoo.tools.translate import _ +from odoo import api, fields, models +from odoo.exceptions import UserError class AccountMoveLine(models.Model): @@ -21,7 +21,8 @@ def create(self, vals): move = self.env['account.move'].browse(vals['move_id']) if move.operating_unit_id: vals['operating_unit_id'] = move.operating_unit_id.id - return super(AccountMoveLine, self).create(vals) + _super = super(AccountMoveLine, self) + return _super.create(vals) @api.model def _query_get(self, domain=None): diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py index a6517b8534..9a7497459a 100644 --- a/account_operating_unit/models/account_payment.py +++ b/account_operating_unit/models/account_payment.py @@ -2,7 +2,7 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models, _ +from odoo import api, fields, models, _ class AccountPayment(models.Model): diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index 248d9eb0ec..f3c2b8ee0b 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -2,9 +2,9 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models -from openerp.tools.translate import _ -from openerp.exceptions import UserError +from odoo import api, fields, models +from odoo.tools.translate import _ +from odoo.exceptions import UserError class ResCompany(models.Model): diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index f442b24ff8..b67c0e5555 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -2,9 +2,9 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models -from openerp.exceptions import ValidationError -from openerp.tools.translate import _ +from odoo import api, fields, models +from odoo.exceptions import ValidationError +from odoo.tools.translate import _ class AccountInvoice(models.Model): diff --git a/account_operating_unit/report/account_invoice_report.py b/account_operating_unit/report/account_invoice_report.py index 24b35d43d9..c61958213a 100644 --- a/account_operating_unit/report/account_invoice_report.py +++ b/account_operating_unit/report/account_invoice_report.py @@ -2,7 +2,7 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models +from odoo import fields, models class AccountInvoiceReport(models.Model): diff --git a/account_operating_unit/tests/test_payment_operating_unit.py b/account_operating_unit/tests/test_payment_operating_unit.py index 7f0d65bda5..d6a8bee2f7 100644 --- a/account_operating_unit/tests/test_payment_operating_unit.py +++ b/account_operating_unit/tests/test_payment_operating_unit.py @@ -2,7 +2,7 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp.addons.account_operating_unit.tests import\ +from odoo.addons.account_operating_unit.tests import\ test_account_operating_unit as test_ou import time diff --git a/account_operating_unit/wizard/account_financial_report.py b/account_operating_unit/wizard/account_financial_report.py index cf0cec4ede..defd7e4844 100644 --- a/account_operating_unit/wizard/account_financial_report.py +++ b/account_operating_unit/wizard/account_financial_report.py @@ -2,7 +2,7 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models +from odoo import fields, models class AccountingReport(models.TransientModel): diff --git a/account_operating_unit/wizard/account_report_common.py b/account_operating_unit/wizard/account_report_common.py index e345eeb640..835e8f5ba8 100644 --- a/account_operating_unit/wizard/account_report_common.py +++ b/account_operating_unit/wizard/account_report_common.py @@ -2,7 +2,7 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models +from odoo import fields, models class AccountCommonReport(models.TransientModel): diff --git a/account_operating_unit/wizard/account_report_trial_balance.py b/account_operating_unit/wizard/account_report_trial_balance.py index f38d759c60..b8bf6a31ac 100644 --- a/account_operating_unit/wizard/account_report_trial_balance.py +++ b/account_operating_unit/wizard/account_report_trial_balance.py @@ -2,7 +2,7 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models +from odoo import fields, models class AccountBalanceReport(models.TransientModel): From c86cc126543377751f728142a2879aa6b2e72d45 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Fri, 10 Feb 2017 11:07:45 +0100 Subject: [PATCH 036/130] Add dependency on analytic_operating_unit. (#62) The analytic account to be selected in customer or supplier invoices must have the operating unit of the invoice as an allowed operating unit. --- account_operating_unit/__manifest__.py | 2 +- account_operating_unit/views/invoice_view.xml | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/account_operating_unit/__manifest__.py b/account_operating_unit/__manifest__.py index 2c6b0053f0..1d7bccbd44 100644 --- a/account_operating_unit/__manifest__.py +++ b/account_operating_unit/__manifest__.py @@ -12,7 +12,7 @@ "Odoo Community Association (OCA)", "website": "https://github.com/OCA/operating-unit", "category": "Accounting & Finance", - "depends": ['account', 'operating_unit'], + "depends": ['account', 'operating_unit', 'analytic_operating_unit'], "license": "LGPL-3", "data": [ "security/account_security.xml", diff --git a/account_operating_unit/views/invoice_view.xml b/account_operating_unit/views/invoice_view.xml index 5cec627aa2..b9bd6e866a 100644 --- a/account_operating_unit/views/invoice_view.xml +++ b/account_operating_unit/views/invoice_view.xml @@ -30,7 +30,7 @@ - + account.invoice.supplier.form account.invoice @@ -40,6 +40,22 @@ options="{'no_create': True}" widget="selection" groups="operating_unit.group_multi_operating_unit"/> + + {'type': type, 'journal_id': journal_id, 'operating_unit': operating_unit_id} + + + [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', 'in', [operating_unit]), ('operating_unit_ids', '=', False)] + + + {'operating_unit': operating_unit_id} + + + [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', 'in', [operating_unit]), ('operating_unit_ids', '=', False)] + @@ -53,6 +69,14 @@ options="{'no_create': True}" widget="selection" groups="operating_unit.group_multi_operating_unit"/> + + {'type': type, 'journal_id': journal_id, 'default_invoice_id': id, 'operating_unit': operating_unit_id} + + + [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', 'in', [operating_unit]), ('operating_unit_ids', '=', False)] + From 8d485dc47afc5206562b7d8be1acefc980ed05d6 Mon Sep 17 00:00:00 2001 From: lreficent Date: Fri, 10 Feb 2017 13:25:15 +0100 Subject: [PATCH 037/130] [FIX] fix wrong iteration. --- account_operating_unit/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index 8c8680fde1..c59c190df4 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -49,7 +49,7 @@ def _check_move_operating_unit(self): for rec in self: if (rec.move_id and rec.move_id.operating_unit_id and rec.operating_unit_id and rec.move_id.operating_unit_id != - self.operating_unit_id): + rec.operating_unit_id): raise UserError(_('Configuration error!\nThe Operating Unit in' ' the Move Line and in the Move must be the' ' same.')) From a9b989907308bc83b768478749d2699d121f1c34 Mon Sep 17 00:00:00 2001 From: aheficent Date: Wed, 24 May 2017 15:46:05 +0200 Subject: [PATCH 038/130] [FIX]When paying, the OU of the invoice should be considered only when a single invoice is being paid --- account_operating_unit/models/account_payment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py index 9a7497459a..15fe9edd0d 100644 --- a/account_operating_unit/models/account_payment.py +++ b/account_operating_unit/models/account_payment.py @@ -22,7 +22,7 @@ def _compute_operating_unit_id(self): def _get_counterpart_move_line_vals(self, invoice=False): res = super(AccountPayment, self)._get_counterpart_move_line_vals(invoice=invoice) - if invoice: + if len(invoice) == 1: res['operating_unit_id'] = invoice.operating_unit_id.id or False else: res['operating_unit_id'] = self.operating_unit_id.id or False From 0e8c373d07db08e18847e9205cbe53104bf36c6b Mon Sep 17 00:00:00 2001 From: Darshan Patel Date: Tue, 4 Jul 2017 14:48:56 +0530 Subject: [PATCH 039/130] [FIX] readonly on OU --- account_operating_unit/__manifest__.py | 2 +- account_operating_unit/models/invoice.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/account_operating_unit/__manifest__.py b/account_operating_unit/__manifest__.py index 1d7bccbd44..91e6b388ec 100644 --- a/account_operating_unit/__manifest__.py +++ b/account_operating_unit/__manifest__.py @@ -6,7 +6,7 @@ "name": 'Accounting with Operating Units', "summary": "Introduces Operating Unit fields in invoices and " "Accounting Entries with clearing account", - "version": "10.0.1.0.0", + "version": "10.0.1.1.0", "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index b67c0e5555..44b96c2f16 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -13,7 +13,10 @@ class AccountInvoice(models.Model): operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit', default=lambda self: self.env['res.users']. - operating_unit_default_get(self._uid)) + operating_unit_default_get(self._uid), + readonly=True, + states={'draft': [('readonly', + False)]}) @api.multi def finalize_invoice_move_lines(self, move_lines): From 64b8c6d017c37f5d3e5352ee05cb8a46f8c82a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Wed, 16 May 2018 14:15:40 +0200 Subject: [PATCH 040/130] Allow selecting OU on all account journals Closes #118 --- account_operating_unit/views/account_journal_view.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/account_operating_unit/views/account_journal_view.xml b/account_operating_unit/views/account_journal_view.xml index 3893eff179..a97bd68ff2 100644 --- a/account_operating_unit/views/account_journal_view.xml +++ b/account_operating_unit/views/account_journal_view.xml @@ -9,8 +9,7 @@ + groups="operating_unit.group_multi_operating_unit"/> From 3a53c18276ef477de6e308f509c3599970cf2a0f Mon Sep 17 00:00:00 2001 From: aaron Date: Mon, 11 Jun 2018 12:02:48 +0200 Subject: [PATCH 041/130] [FIX]PYLINT mainly --- account_operating_unit/__manifest__.py | 1 + account_operating_unit/tests/test_payment_operating_unit.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/account_operating_unit/__manifest__.py b/account_operating_unit/__manifest__.py index 91e6b388ec..9eaee8e0ac 100644 --- a/account_operating_unit/__manifest__.py +++ b/account_operating_unit/__manifest__.py @@ -24,6 +24,7 @@ "views/account_invoice_report_view.xml", "views/report_financial.xml", "views/report_trialbalance.xml", + "views/report_agedpartnerbalance.xml", "wizard/account_report_common_view.xml", "wizard/account_financial_report_view.xml", "wizard/account_report_trial_balance_view.xml", diff --git a/account_operating_unit/tests/test_payment_operating_unit.py b/account_operating_unit/tests/test_payment_operating_unit.py index d6a8bee2f7..13f9cf6a11 100644 --- a/account_operating_unit/tests/test_payment_operating_unit.py +++ b/account_operating_unit/tests/test_payment_operating_unit.py @@ -2,8 +2,9 @@ # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo.addons.account_operating_unit.tests import\ +from odoo.addons.account_operating_unit.tests import ( test_account_operating_unit as test_ou + ) # noqa import time From 469de19afecf4f558dfc5981099a8a2a8dad909d Mon Sep 17 00:00:00 2001 From: Isabel Esparza Date: Tue, 10 Apr 2018 12:20:52 -0500 Subject: [PATCH 042/130] [FIX][account_payment]Fix in the internal transfers amount currency --- account_operating_unit/models/account_payment.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py index 15fe9edd0d..3dc2d1dcf1 100644 --- a/account_operating_unit/models/account_payment.py +++ b/account_operating_unit/models/account_payment.py @@ -47,7 +47,7 @@ def _get_dst_liquidity_aml_dict_vals(self): if self.currency_id != self.company_id.currency_id: dst_liquidity_aml_dict.update({ 'currency_id': self.currency_id.id, - 'amount_currency': -self.amount, + 'amount_currency': self.amount, }) dst_liquidity_aml_dict.update({ @@ -62,6 +62,11 @@ def _get_transfer_debit_aml_dict_vals(self): 'account_id': self.company_id.transfer_account_id.id, 'journal_id': self.destination_journal_id.id } + if self.currency_id != self.company_id.currency_id: + transfer_debit_aml_dict.update({ + 'currency_id': self.currency_id.id, + 'amount_currency': -self.amount, + }) transfer_debit_aml_dict.update({ 'operating_unit_id': self.journal_id.operating_unit_id.id or False From bbf08be793756c3d20951ce84b3de64aa4d07ff4 Mon Sep 17 00:00:00 2001 From: Michael Aldrin Villamar Date: Tue, 17 Jul 2018 12:55:42 +0200 Subject: [PATCH 043/130] [MIG]account_operating_unit to v11 --- account_operating_unit/README.rst | 4 +++- account_operating_unit/__init__.py | 4 +--- account_operating_unit/__manifest__.py | 5 ++--- account_operating_unit/models/__init__.py | 4 +--- account_operating_unit/models/account_journal.py | 2 +- account_operating_unit/models/account_move.py | 4 ++-- account_operating_unit/models/account_payment.py | 9 ++------- account_operating_unit/models/company.py | 2 +- account_operating_unit/models/invoice.py | 2 +- account_operating_unit/report/__init__.py | 4 +--- .../report/account_invoice_report.py | 2 +- account_operating_unit/tests/__init__.py | 4 +--- .../tests/test_account_operating_unit.py | 2 +- .../tests/test_cross_ou_journal_entry.py | 1 - .../tests/test_invoice_operating_unit.py | 2 +- .../tests/test_operating_unit_security.py | 2 +- .../tests/test_payment_operating_unit.py | 9 ++++----- account_operating_unit/views/account_move_view.xml | 13 ------------- account_operating_unit/views/invoice_view.xml | 6 +++--- .../views/report_agedpartnerbalance.xml | 4 ++-- account_operating_unit/views/report_financial.xml | 2 +- .../views/report_trialbalance.xml | 2 +- account_operating_unit/wizard/__init__.py | 4 +--- .../wizard/account_financial_report.py | 2 +- .../wizard/account_report_common.py | 2 +- .../wizard/account_report_trial_balance.py | 2 +- 26 files changed, 35 insertions(+), 64 deletions(-) diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 4e802b1e8e..1d3a847ee0 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -85,7 +85,7 @@ Usage .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/213/10.0 + :target: https://runbot.odoo-community.org/runbot/213/11.0 Known issues / Roadmap ====================== @@ -119,6 +119,8 @@ Contributors * Jordi Ballester Alomar * Aarón Henríquez * Serpent Consulting Services Pvt. Ltd. +* WilldooIT Pty Ltd +* Michael Villamar Maintainer ---------- diff --git a/account_operating_unit/__init__.py b/account_operating_unit/__init__.py index a647cd034c..06448aae56 100644 --- a/account_operating_unit/__init__.py +++ b/account_operating_unit/__init__.py @@ -1,7 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2016-17 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from . import models from . import wizard from . import report diff --git a/account_operating_unit/__manifest__.py b/account_operating_unit/__manifest__.py index 9eaee8e0ac..179f15cdc8 100644 --- a/account_operating_unit/__manifest__.py +++ b/account_operating_unit/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). @@ -6,9 +5,10 @@ "name": 'Accounting with Operating Units', "summary": "Introduces Operating Unit fields in invoices and " "Accounting Entries with clearing account", - "version": "10.0.1.1.0", + "version": "11.0.1.0.0", "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," + "WilldooIT Pty Ltd," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/operating-unit", "category": "Accounting & Finance", @@ -24,7 +24,6 @@ "views/account_invoice_report_view.xml", "views/report_financial.xml", "views/report_trialbalance.xml", - "views/report_agedpartnerbalance.xml", "wizard/account_report_common_view.xml", "wizard/account_financial_report_view.xml", "wizard/account_report_trial_balance_view.xml", diff --git a/account_operating_unit/models/__init__.py b/account_operating_unit/models/__init__.py index f1237de449..a3df860d0f 100644 --- a/account_operating_unit/models/__init__.py +++ b/account_operating_unit/models/__init__.py @@ -1,7 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2016-17 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from . import company from . import account_journal from . import account_move diff --git a/account_operating_unit/models/account_journal.py b/account_operating_unit/models/account_journal.py index aac87cb468..8e826f6c65 100644 --- a/account_operating_unit/models/account_journal.py +++ b/account_operating_unit/models/account_journal.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from odoo import api, fields, models, _ from odoo.exceptions import UserError diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index c59c190df4..759a2f91c2 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from odoo.tools.translate import _ from odoo import api, fields, models from odoo.exceptions import UserError @@ -114,7 +114,7 @@ def post(self): # Create balancing entries for un-balanced OU's. ou_balances = self._check_ou_balance(move) amls = [] - for ou_id in ou_balances.keys(): + for ou_id in list(ou_balances.keys()): # If the OU is already balanced, then do not continue if move.company_id.currency_id.is_zero(ou_balances[ou_id]): continue diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py index 3dc2d1dcf1..e09b2c7899 100644 --- a/account_operating_unit/models/account_payment.py +++ b/account_operating_unit/models/account_payment.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from odoo import api, fields, models, _ @@ -47,7 +47,7 @@ def _get_dst_liquidity_aml_dict_vals(self): if self.currency_id != self.company_id.currency_id: dst_liquidity_aml_dict.update({ 'currency_id': self.currency_id.id, - 'amount_currency': self.amount, + 'amount_currency': -self.amount, }) dst_liquidity_aml_dict.update({ @@ -62,11 +62,6 @@ def _get_transfer_debit_aml_dict_vals(self): 'account_id': self.company_id.transfer_account_id.id, 'journal_id': self.destination_journal_id.id } - if self.currency_id != self.company_id.currency_id: - transfer_debit_aml_dict.update({ - 'currency_id': self.currency_id.id, - 'amount_currency': -self.amount, - }) transfer_debit_aml_dict.update({ 'operating_unit_id': self.journal_id.operating_unit_id.id or False diff --git a/account_operating_unit/models/company.py b/account_operating_unit/models/company.py index f3c2b8ee0b..5ef3dbb6ae 100644 --- a/account_operating_unit/models/company.py +++ b/account_operating_unit/models/company.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from odoo import api, fields, models from odoo.tools.translate import _ from odoo.exceptions import UserError diff --git a/account_operating_unit/models/invoice.py b/account_operating_unit/models/invoice.py index 44b96c2f16..9406d73957 100644 --- a/account_operating_unit/models/invoice.py +++ b/account_operating_unit/models/invoice.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from odoo import api, fields, models from odoo.exceptions import ValidationError from odoo.tools.translate import _ diff --git a/account_operating_unit/report/__init__.py b/account_operating_unit/report/__init__.py index 5be7018e74..828ca7dd4d 100644 --- a/account_operating_unit/report/__init__.py +++ b/account_operating_unit/report/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# © 2016-17 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from . import account_invoice_report diff --git a/account_operating_unit/report/account_invoice_report.py b/account_operating_unit/report/account_invoice_report.py index c61958213a..ba8e3df21c 100644 --- a/account_operating_unit/report/account_invoice_report.py +++ b/account_operating_unit/report/account_invoice_report.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from odoo import fields, models diff --git a/account_operating_unit/tests/__init__.py b/account_operating_unit/tests/__init__.py index 9ef001663c..071cbac008 100644 --- a/account_operating_unit/tests/__init__.py +++ b/account_operating_unit/tests/__init__.py @@ -1,7 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2016-17 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from . import test_account_operating_unit from . import test_invoice_operating_unit from . import test_cross_ou_journal_entry diff --git a/account_operating_unit/tests/test_account_operating_unit.py b/account_operating_unit/tests/test_account_operating_unit.py index e73ac94d56..53d4e73d4d 100644 --- a/account_operating_unit/tests/test_account_operating_unit.py +++ b/account_operating_unit/tests/test_account_operating_unit.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from odoo.addons.account.tests.account_test_classes import AccountingTestCase diff --git a/account_operating_unit/tests/test_cross_ou_journal_entry.py b/account_operating_unit/tests/test_cross_ou_journal_entry.py index 566cbab64c..9d0d9fa2a8 100644 --- a/account_operating_unit/tests/test_cross_ou_journal_entry.py +++ b/account_operating_unit/tests/test_cross_ou_journal_entry.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). diff --git a/account_operating_unit/tests/test_invoice_operating_unit.py b/account_operating_unit/tests/test_invoice_operating_unit.py index b7f7a3b10a..77907c87d8 100644 --- a/account_operating_unit/tests/test_invoice_operating_unit.py +++ b/account_operating_unit/tests/test_invoice_operating_unit.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_operating_unit_security.py b/account_operating_unit/tests/test_operating_unit_security.py index 17cd77b0cc..6ebce38c2a 100644 --- a/account_operating_unit/tests/test_operating_unit_security.py +++ b/account_operating_unit/tests/test_operating_unit_security.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + from . import test_account_operating_unit as test_ou diff --git a/account_operating_unit/tests/test_payment_operating_unit.py b/account_operating_unit/tests/test_payment_operating_unit.py index 13f9cf6a11..273a844c6b 100644 --- a/account_operating_unit/tests/test_payment_operating_unit.py +++ b/account_operating_unit/tests/test_payment_operating_unit.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- # © 2016-17 Eficent Business and IT Consulting Services S.L. # © 2016 Serpent Consulting Services Pvt. Ltd. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo.addons.account_operating_unit.tests import ( + +from odoo.addons.account_operating_unit.tests import\ test_account_operating_unit as test_ou - ) # noqa import time @@ -29,9 +28,9 @@ def test_payment_from_invoice(self): 'payment_method_id': self.payment_method_manual_in.id }) - register_payments.create_payment() + register_payments.create_payments() payment = self.payment_model.search([], order="id desc", limit=1) - self.assertAlmostEquals(payment.amount, 115000) + self.assertAlmostEqual(payment.amount, 115000) self.assertEqual(payment.state, 'posted') self.assertEqual(self.invoice.state, 'paid') diff --git a/account_operating_unit/views/account_move_view.xml b/account_operating_unit/views/account_move_view.xml index d881f0408a..22fd12770b 100644 --- a/account_operating_unit/views/account_move_view.xml +++ b/account_operating_unit/views/account_move_view.xml @@ -14,19 +14,6 @@ - - account.move.line.form2 - account.move.line - - - - - - - - account.move.line.tree account.move.line diff --git a/account_operating_unit/views/invoice_view.xml b/account_operating_unit/views/invoice_view.xml index b9bd6e866a..c6ebfd981f 100644 --- a/account_operating_unit/views/invoice_view.xml +++ b/account_operating_unit/views/invoice_view.xml @@ -46,7 +46,7 @@ - [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', 'in', [operating_unit]), ('operating_unit_ids', '=', False)] + [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', '=', context.get('operating_unit', False)), ('operating_unit_ids', '=', False)] @@ -54,7 +54,7 @@ - [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', 'in', [operating_unit]), ('operating_unit_ids', '=', False)] + [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', '=', context.get('operating_unit', False)), ('operating_unit_ids', '=', False)] @@ -75,7 +75,7 @@ - [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', 'in', [operating_unit]), ('operating_unit_ids', '=', False)] + [('company_id', '=', parent.company_id), '|', ('operating_unit_ids', '=', context.get('operating_unit', False)), ('operating_unit_ids', '=', False)] diff --git a/account_operating_unit/views/report_agedpartnerbalance.xml b/account_operating_unit/views/report_agedpartnerbalance.xml index d8c6eced3d..0d3a36aa0a 100644 --- a/account_operating_unit/views/report_agedpartnerbalance.xml +++ b/account_operating_unit/views/report_agedpartnerbalance.xml @@ -3,8 +3,8 @@