From 50a2b6f455f2b65992e7f91d183f9f9a3ac16783 Mon Sep 17 00:00:00 2001
From: jbeficent
Date: Fri, 16 Sep 2016 01:45:49 +0200
Subject: [PATCH 01/49] stock_operating_unit
---
stock_operating_unit/README.rst | 70 ++++++++
stock_operating_unit/__init__.py | 6 +
stock_operating_unit/__openerp__.py | 27 +++
stock_operating_unit/data/stock_data.xml | 14 ++
stock_operating_unit/demo/stock_demo.xml | 57 +++++++
stock_operating_unit/model/__init__.py | 6 +
stock_operating_unit/model/stock.py | 144 ++++++++++++++++
.../security/stock_security.xml | 63 +++++++
.../static/description/icon.png | Bin 0 -> 9455 bytes
stock_operating_unit/tests/__init__.py | 8 +
.../tests/test_stock_operating_unit.py | 97 +++++++++++
.../tests/test_stock_picking.py | 21 +++
.../tests/test_stock_security.py | 68 ++++++++
stock_operating_unit/view/stock.xml | 158 ++++++++++++++++++
14 files changed, 739 insertions(+)
create mode 100644 stock_operating_unit/README.rst
create mode 100644 stock_operating_unit/__init__.py
create mode 100644 stock_operating_unit/__openerp__.py
create mode 100644 stock_operating_unit/data/stock_data.xml
create mode 100644 stock_operating_unit/demo/stock_demo.xml
create mode 100644 stock_operating_unit/model/__init__.py
create mode 100644 stock_operating_unit/model/stock.py
create mode 100644 stock_operating_unit/security/stock_security.xml
create mode 100644 stock_operating_unit/static/description/icon.png
create mode 100644 stock_operating_unit/tests/__init__.py
create mode 100644 stock_operating_unit/tests/test_stock_operating_unit.py
create mode 100644 stock_operating_unit/tests/test_stock_picking.py
create mode 100644 stock_operating_unit/tests/test_stock_security.py
create mode 100644 stock_operating_unit/view/stock.xml
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
new file mode 100644
index 0000000000..71be286e3b
--- /dev/null
+++ b/stock_operating_unit/README.rst
@@ -0,0 +1,70 @@
+.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg
+ :target: https://www.gnu.org/licenses/lgpl.html
+ :alt: License: LGPL-3
+
+==========================
+Stock with Operating Units
+==========================
+
+This module introduces the following features:
+- Adds the operating unit to the Warehouse.
+- Adds the operating unit to the Stock Location.
+- Adds the requesting operating unit to stock pickings.
+- Implements user's security access rules.
+
+
+Configuration
+=============
+
+To configure this module, you need to:
+
+* Assign Operating Unit to Warehouses.
+* Assign Operating Unit to Stock Locations.
+
+Usage
+=====
+
+This module defines the operating unit entity and the user's security rules.
+Other modules extend the standard Odoo apps with the OU.
+
+.. 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.
diff --git a/stock_operating_unit/__init__.py b/stock_operating_unit/__init__.py
new file mode 100644
index 0000000000..42481c3482
--- /dev/null
+++ b/stock_operating_unit/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# © 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 model
diff --git a/stock_operating_unit/__openerp__.py b/stock_operating_unit/__openerp__.py
new file mode 100644
index 0000000000..9afa5f3975
--- /dev/null
+++ b/stock_operating_unit/__openerp__.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# © 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).
+
+{
+ "name": "Stock with Operating Units",
+ "summary": "An operating unit (OU) is an organizational entity part of a\
+ company",
+ "version": "9.0.1.0.0",
+ "category": "Generic Modules/Sales & Purchases",
+ "author": "Eficent, Serpent Consulting Services Pvt. Ltd., "
+ "Odoo Community Association (OCA)",
+ "license": "LGPL-3",
+ "website": "http://www.eficent.com",
+ "depends": ["stock", "account_operating_unit"],
+ "data": [
+ "security/stock_security.xml",
+ "data/stock_data.xml",
+ "view/stock.xml",
+ ],
+ "demo": [
+ "demo/stock_demo.xml",
+ ],
+ "installable": True,
+}
diff --git a/stock_operating_unit/data/stock_data.xml b/stock_operating_unit/data/stock_data.xml
new file mode 100644
index 0000000000..7229f533bc
--- /dev/null
+++ b/stock_operating_unit/data/stock_data.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/stock_operating_unit/demo/stock_demo.xml b/stock_operating_unit/demo/stock_demo.xml
new file mode 100644
index 0000000000..40dbb9cca9
--- /dev/null
+++ b/stock_operating_unit/demo/stock_demo.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Your company child
+
+
+
+ Chicago
+ CH
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ B2B Warehouse
+ B2B
+
+
+
+
+
+
+
+ B2C Warehouse
+ B2C
+
+
+
+
+
+
+
diff --git a/stock_operating_unit/model/__init__.py b/stock_operating_unit/model/__init__.py
new file mode 100644
index 0000000000..49fb8dc2e9
--- /dev/null
+++ b/stock_operating_unit/model/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# © 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 stock
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
new file mode 100644
index 0000000000..49e415e390
--- /dev/null
+++ b/stock_operating_unit/model/stock.py
@@ -0,0 +1,144 @@
+# -*- coding: utf-8 -*-
+# © 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 _
+from openerp import api, fields, models
+from openerp.exceptions import Warning as UserError
+
+
+class StockWarehouse(models.Model):
+ _inherit = "stock.warehouse"
+
+ operating_unit_id = fields.Many2one('operating.unit',
+ 'Operating Unit',
+ default=lambda self:
+ self.env['res.users'].
+ operating_unit_default_get(self._uid))
+
+ @api.multi
+ @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:
+ raise UserError(_('Configuration error!\nThe Company in the\
+ Stock Warehouse and in the Operating Unit must be the same.'))
+
+
+class StockLocation(models.Model):
+ _inherit = 'stock.location'
+
+ operating_unit_id = fields.Many2one('operating.unit',
+ 'Operating Unit')
+
+ @api.multi
+ @api.constrains('operating_unit_id')
+ def _check_warehouse_operating_unit(self):
+ for rec in self:
+ warehouse_obj = self.env['stock.warehouse']
+ warehouse = warehouse_obj.search([('wh_input_stock_loc_id', 'in',
+ rec.ids)])
+ for w in warehouse:
+ if rec.operating_unit_id != w.operating_unit_id:
+ raise UserError(_('Configuration error!\nThis location is\
+ assigned to a warehouse that belongs to a\
+ different operating unit.'))
+ warehouse = warehouse_obj.search([('lot_stock_id', 'in', rec.ids)])
+ for w in warehouse:
+ if self.operating_unit_id != w.operating_unit_id:
+ raise UserError(_('Configuration error!\nThis location is\
+ assigned to a warehouse that belongs to a\
+ different operating unit.'))
+ warehouse = warehouse_obj.search([('wh_output_stock_loc_id', 'in',
+ rec.ids)])
+ for w in warehouse:
+ if rec.operating_unit_id != w.operating_unit_id:
+ raise UserError(_('Configuration error!\nThis location is\
+ assigned to a warehouse that belongs to a different\
+ operating unit.'))
+
+ @api.multi
+ @api.constrains('operating_unit_id')
+ def _check_required_operating_unit(self):
+ for rec in self:
+ if rec.usage == 'internal' and not rec.operating_unit_id:
+ raise UserError(_('Configuration error!\nThe operating unit\
+ should be assigned to internal locations and to non other.'))
+ if rec.usage != 'internal' and rec.operating_unit_id:
+ raise UserError(_('Configuration error!\nThe operating unit\
+ should be assigned to internal locations and to non other.'))
+
+ @api.multi
+ @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:
+ raise UserError(_('Configuration error!\nThe Company in the\
+ Stock Location and in the Operating Unit must be the same.'))
+
+ @api.multi
+ @api.constrains('operating_unit_id', 'location_id')
+ def _check_parent_operating_unit(self):
+ for rec in self:
+ if (rec.location_id and rec.location_id.usage == 'internal'
+ and rec.operating_unit_id and rec.operating_unit_id
+ != rec.location_id.operating_unit_id):
+ raise UserError(_('Configuration error!\nThe Parent\
+ Stock Location must belong to the same Operating Unit.'))
+
+
+class StockPicking(models.Model):
+ _inherit = 'stock.picking'
+
+ operating_unit_id = fields.Many2one('operating.unit',
+ 'Requesting Operating Unit',
+ default=lambda self:
+ self.env['res.users'].
+ operating_unit_default_get(self._uid))
+
+ @api.multi
+ @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:
+ raise UserError(_('Configuration error!\nThe Company in the\
+ Stock Picking and in the Operating Unit must be the same.'))
+
+ @api.multi
+ @api.constrains('operating_unit_id', 'move_lines')
+ def _check_stock_move_operating_unit(self):
+ for rec in self:
+ if not rec.operating_unit_id:
+ return True
+ operating_unit = rec.operating_unit_id
+ for sm in rec.move_lines:
+ if (
+ sm.location_id and
+ sm.location_id.operating_unit_id and
+ operating_unit != sm.location_id.operating_unit_id
+ ) and (
+ sm.location_dest_id and
+ sm.location_dest_id.operating_unit_id and
+ operating_unit !=
+ sm.location_dest_id.operating_unit_id
+ ):
+ raise UserError(_('Configuration error!\nThe Stock moves\
+ must be related to a location (source or destination)\
+ that belongs to the requesting Operating Unit.'))
+
+
+class StockMove(models.Model):
+ _inherit = 'stock.move'
+
+ operating_unit_id =\
+ fields.Many2one('operating.unit',
+ related='location_id.operating_unit_id',
+ string='Source Location Operating Unit', readonly=True)
+ operating_unit_dest_id =\
+ fields.Many2one('operating.unit',
+ related='location_dest_id.operating_unit_id',
+ string='Dest. Location Operating Unit', readonly=True)
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
new file mode 100644
index 0000000000..80b9fd1c3c
--- /dev/null
+++ b/stock_operating_unit/security/stock_security.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+ ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Warehouses from allowed operating units
+
+
+
+
+
+
+
+
+
+ ['|',('warehouse_id.operating_unit_id','=',False),('warehouse_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Stock Picking Type from allowed operating units
+
+
+
+
+
+
+
+
+
+ ['|', ('operating_unit_id','in',[g.id for g
+ in user.operating_unit_ids]), ('operating_unit_id','=', False)]
+ Stock locations from allowed operating units
+
+
+
+
+
+
+
+
+
+ ['|',('location_id.operating_unit_id','=',False),('location_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids]),
+ '|',('location_dest_id.operating_unit_id','=',False),('location_dest_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Stock moves from allowed operating units
+
+
+
+
+
+
+
+
+
+ ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Stock pickings from allowed operating units
+
+
+
+
+
+
+
+
+
diff --git a/stock_operating_unit/static/description/icon.png b/stock_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)`y_~Hnd9AUX7h-H?jVuU|}My+C=TjH(jKz
zqMVr0re3S$H@t{zI95qa)+Crz*5Zj}Ao%4Z><+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+Zls4&}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/stock_operating_unit/tests/__init__.py b/stock_operating_unit/tests/__init__.py
new file mode 100644
index 0000000000..4101fcef9f
--- /dev/null
+++ b/stock_operating_unit/tests/__init__.py
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+# © 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_stock_operating_unit
+from . import test_stock_picking
+from . import test_stock_security
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
new file mode 100644
index 0000000000..ff97c067ff
--- /dev/null
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -0,0 +1,97 @@
+# -*- coding: utf-8 -*-
+# © 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.stock.tests import common
+
+
+class TestStockOperatingUnit(common.TestStockCommon):
+
+ def setUp(self):
+ super(TestStockOperatingUnit, self).setUp()
+ self.ResUsers = self.env['res.users']
+ self.WarehouseObj = self.env['stock.warehouse']
+ self.LocationObj = self.env['stock.location']
+ # company
+ self.company1 = self.env.ref('base.main_company')
+ # groups
+ self.group_purchase_user = self.env.ref('purchase.group_purchase_user')
+ self.group_stock_manager = self.env.ref('stock.group_stock_manager')
+ # Main Operating Unit
+ self.ou1 = self.env.ref('operating_unit.main_operating_unit')
+ # B2C Operating Unit
+ self.b2c = self.env.ref('operating_unit.b2c_operating_unit')
+ # 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')
+ # Locations
+ b2c_wh = self.env.ref('stock_operating_unit.stock_warehouse_b2c')
+ b2c_wh.lot_stock_id.write({'operating_unit_id': self.b2c.id})
+ self.location_b2c_id = b2c_wh.lot_stock_id.id
+ self.b2c_type_in_id = b2c_wh.in_type_id.id
+ self.b2c_type_int_id = b2c_wh.int_type_id.id
+ # Create users
+ self.user1_id = self._create_user('stock_user_1',
+ [self.group_stock_manager],
+ self.company1,
+ [self.ou1, self.b2c])
+ self.user2_id = self._create_user('stock_user_2',
+ [self.group_stock_manager],
+ self.company1,
+ [self.b2c])
+ # Create Incoming Shipments
+ self.picking_in1 = self._create_picking(self.user1_id,
+ self.ou1.id,
+ self.b2c_type_in_id,
+ self.supplier_location,
+ self.stock_location)
+ self.picking_in2 = self._create_picking(self.user2_id,
+ self.b2c.id,
+ self.b2c_type_in_id,
+ self.supplier_location,
+ self.location_b2c_id)
+ # Create Internal Shipment
+ self.picking_int = self._create_picking(self.user1_id,
+ self.b2c.id,
+ self.b2c_type_int_id,
+ self.stock_location,
+ self.location_b2c_id)
+
+ def _create_user(self, login, groups, company, operating_units):
+ """ Create a user."""
+ group_ids = [group.id for group in groups]
+ user =\
+ self.ResUsers.with_context({'no_reset_password': True}).\
+ create({
+ 'name': 'Stock User',
+ 'login': login,
+ 'password': 'demo',
+ 'email': 'chicago@yourcompany.com',
+ 'company_id': company.id,
+ 'company_ids': [(4, company.id)],
+ 'operating_unit_ids': [(4, ou.id) for ou in operating_units],
+ 'groups_id': [(6, 0, group_ids)]
+ })
+ return user.id
+
+ def _create_picking(self, user_id, ou_id, picking_type, src_loc_id,
+ dest_loc_id):
+ """Create a Picking."""
+ picking = self.PickingObj.sudo(user_id).create({
+ 'picking_type_id': picking_type,
+ 'location_id': src_loc_id,
+ 'location_dest_id': dest_loc_id,
+ 'operating_unit_id': ou_id,
+ })
+ self.MoveObj.sudo(user_id).create({
+ 'name': 'a move',
+ 'product_id': self.productA.id,
+ 'product_uom_qty': 3.0,
+ 'product_uom': self.productA.uom_id.id,
+ 'picking_id': picking.id,
+ 'location_id': src_loc_id,
+ 'location_dest_id': dest_loc_id,
+ })
+ return picking
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
new file mode 100644
index 0000000000..5b0f9732b5
--- /dev/null
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# © 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_stock_operating_unit as test_stock_ou
+
+
+class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
+
+ def test_stock_picking_ou(self):
+ """Test Pickings of Stock Operating Unit"""
+ picking_ids = self.PickingObj.sudo(self.user1_id).\
+ search([('id', '=', self.picking_in1.id)]).ids
+ self.assertNotEqual(picking_ids, [], '')
+ picking_ids = self.PickingObj.sudo(self.user2_id).\
+ search([('id', '=', self.picking_in2.id)]).ids
+ self.assertNotEqual(picking_ids, [])
+ picking_ids = self.PickingObj.sudo(self.user1_id).\
+ search([('id', '=', self.picking_int.id)]).ids
+ self.assertNotEqual(picking_ids, [])
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
new file mode 100644
index 0000000000..dc710d64d1
--- /dev/null
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+# © 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_stock_operating_unit as test_stock_ou
+
+
+class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
+
+ def test_stock_ou_security(self):
+ """Test Security of Stock Operating Unit"""
+ # User 1 can list the warehouses assigned to
+ # Main and B2C OU
+ wh_ids =\
+ self.WarehouseObj.sudo(self.user1_id).\
+ search([('operating_unit_id', 'in',
+ [self.ou1.id, self.b2c.id])]).ids
+ self.assertNotEqual(wh_ids, [], 'User does not have access to'
+ 'Warehouses which belong to Main and B2C'
+ 'Operating Unit.')
+ # User 1 can list the locations assigned to Main and b2c OU
+ location_ids =\
+ self.LocationObj.sudo(self.user1_id).\
+ search([('operating_unit_id', 'in',
+ [self.ou1.id, self.b2c.id])]).ids
+ self.assertNotEqual(location_ids, [], 'User does not have access to'
+ 'Locations which belong to Main and B2C'
+ 'Operating Unit.')
+ # User 2 cannot list the warehouses assigned to Main OU
+ wh_ids =\
+ self.WarehouseObj.sudo(self.user2_id).\
+ search([('operating_unit_id', '=', self.ou1.id)]).ids
+ self.assertEqual(wh_ids, [], 'User 2 should not be able to list'
+ 'the warehouses assigned to Main Operating Unit.')
+ # User 2 cannot list the locations assigned to Main OU
+ location_ids =\
+ self.LocationObj.sudo(self.user2_id).\
+ search([('operating_unit_id', 'in',
+ [self.ou1.id])]).ids
+ self.assertEqual(location_ids, [], 'User 2 should not be able to list'
+ 'the locations assigned to Main OU.')
+ pickings = [self.picking_in1.id, self.picking_in2.id,
+ self.picking_int.id]
+ # User 1 can list the pickings 1, 2, 3
+ picking_ids =\
+ self.PickingObj.sudo(self.user1_id).search([('id', 'in',
+ pickings)]).ids
+ self.assertNotEqual(picking_ids, [], 'User 1 cannot list the'
+ 'pickings assigned to pickings 1, 2, 3.')
+ # User 1 can list the stock moves assigned to pickings 1, 2, 3
+ move_ids =\
+ self.MoveObj.sudo(self.user1_id).search([('picking_id', 'in',
+ pickings)]).ids
+ self.assertNotEqual(move_ids, [], 'User 1 cannot list the'
+ 'stock moves assigned to pickings 1, 2, 3.')
+ # User 2 cannot list the the stock moves assigned to picking 1
+ move_ids =\
+ self.MoveObj.sudo(self.user2_id).\
+ search([('picking_id', '=', self.picking_in1.id)]).ids
+ self.assertEqual(move_ids, [], 'User 2 should not be able to list'
+ 'the stock moves assigned to picking 1.')
+ # User 2 cannot list the pickings 1
+ picking_ids =\
+ self.PickingObj.sudo(self.user2_id).\
+ search([('id', '=', self.picking_in1.id)]).ids
+ self.assertEqual(picking_ids, [], 'User 2 should not be able to list'
+ 'the picking 1.')
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
new file mode 100644
index 0000000000..462c611953
--- /dev/null
+++ b/stock_operating_unit/view/stock.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+ stock.warehouse
+ stock.warehouse
+
+
+
+
+
+
+
+
+
+ stock.warehouse.tree
+ stock.warehouse
+
+
+
+
+
+
+
+
+
+ stock.location.form
+ stock.location
+
+
+
+
+
+
+
+
+
+ stock.location.tree
+ stock.location
+
+
+
+
+
+
+
+
+
+ stock.location.search
+ stock.location
+
+
+
+
+
+
+
+
+
+ stock.picking.tree
+ stock.picking
+
+
+
+
+
+
+
+
+
+ stock.picking.form
+ stock.picking
+
+
+
+
+
+
+
+
+
+ stock.picking.internal.search
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+
+ stock.move.tree
+ stock.move
+
+
+
+
+
+
+
+
+
+
+
+
+ stock.move.tree
+ stock.move
+
+
+
+
+
+
+
+
+
+
+
+
+ Stock Moves
+ stock.move
+ move_history_ids
+
+
+
+
+
+
+
+
+
+
+
+
+ stock.move.form
+ stock.move
+
+
+
+
+
+
+
+
+
+
+
+
+
From 5138c080bfaa10151cf81837175ce701cb57ba57 Mon Sep 17 00:00:00 2001
From: jbeficent
Date: Wed, 28 Sep 2016 14:07:18 +0200
Subject: [PATCH 02/49] flake8 issues
---
stock_operating_unit/__init__.py | 5 ++---
stock_operating_unit/__openerp__.py | 5 ++---
stock_operating_unit/model/__init__.py | 5 ++---
stock_operating_unit/model/stock.py | 11 +++++------
.../tests/test_stock_operating_unit.py | 6 ++----
stock_operating_unit/tests/test_stock_picking.py | 5 ++---
stock_operating_unit/tests/test_stock_security.py | 5 ++---
7 files changed, 17 insertions(+), 25 deletions(-)
diff --git a/stock_operating_unit/__init__.py b/stock_operating_unit/__init__.py
index 42481c3482..54776d1e38 100644
--- a/stock_operating_unit/__init__.py
+++ b/stock_operating_unit/__init__.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 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 . import model
diff --git a/stock_operating_unit/__openerp__.py b/stock_operating_unit/__openerp__.py
index 9afa5f3975..c861ba0f9c 100644
--- a/stock_operating_unit/__openerp__.py
+++ b/stock_operating_unit/__openerp__.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 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).
{
diff --git a/stock_operating_unit/model/__init__.py b/stock_operating_unit/model/__init__.py
index 49fb8dc2e9..a05fa0038b 100644
--- a/stock_operating_unit/model/__init__.py
+++ b/stock_operating_unit/model/__init__.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 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 . import stock
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 49e415e390..bf1de7cce7 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 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.tools.translate import _
from openerp import api, fields, models
-from openerp.exceptions import Warning as UserError
+from openerp.exceptions import Warning as UserError
class StockWarehouse(models.Model):
@@ -84,8 +83,8 @@ def _check_company_operating_unit(self):
def _check_parent_operating_unit(self):
for rec in self:
if (rec.location_id and rec.location_id.usage == 'internal'
- and rec.operating_unit_id and rec.operating_unit_id
- != rec.location_id.operating_unit_id):
+ and rec.operating_unit_id and rec.operating_unit_id !=
+ rec.location_id.operating_unit_id):
raise UserError(_('Configuration error!\nThe Parent\
Stock Location must belong to the same Operating Unit.'))
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index ff97c067ff..291ff1ab7c 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 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.addons.stock.tests import common
@@ -16,7 +15,6 @@ def setUp(self):
# company
self.company1 = self.env.ref('base.main_company')
# groups
- self.group_purchase_user = self.env.ref('purchase.group_purchase_user')
self.group_stock_manager = self.env.ref('stock.group_stock_manager')
# Main Operating Unit
self.ou1 = self.env.ref('operating_unit.main_operating_unit')
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
index 5b0f9732b5..7d0298067c 100644
--- a/stock_operating_unit/tests/test_stock_picking.py
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 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 . import test_stock_operating_unit as test_stock_ou
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index dc710d64d1..e738653d0e 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 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 . import test_stock_operating_unit as test_stock_ou
From 39c96b1c20e88a4c1cd1b99777314dcbd485412b Mon Sep 17 00:00:00 2001
From: jbeficent
Date: Wed, 28 Sep 2016 14:17:11 +0200
Subject: [PATCH 03/49] flake 8
---
stock_operating_unit/model/stock.py | 10 +++++++---
stock_operating_unit/tests/test_stock_security.py | 4 ++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index bf1de7cce7..9a588839d2 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -82,9 +82,13 @@ def _check_company_operating_unit(self):
@api.constrains('operating_unit_id', 'location_id')
def _check_parent_operating_unit(self):
for rec in self:
- if (rec.location_id and rec.location_id.usage == 'internal'
- and rec.operating_unit_id and rec.operating_unit_id !=
- rec.location_id.operating_unit_id):
+ if (
+ rec.location_id
+ and rec.location_id.usage == 'internal'
+ and rec.operating_unit_id
+ and rec.operating_unit_id !=
+ rec.location_id.operating_unit_id
+ ):
raise UserError(_('Configuration error!\nThe Parent\
Stock Location must belong to the same Operating Unit.'))
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index e738653d0e..20c2595eef 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -57,8 +57,8 @@ def test_stock_ou_security(self):
move_ids =\
self.MoveObj.sudo(self.user2_id).\
search([('picking_id', '=', self.picking_in1.id)]).ids
- self.assertEqual(move_ids, [], 'User 2 should not be able to list'
- 'the stock moves assigned to picking 1.')
+ self.assertEqual(move_ids, [], 'User 2 should not be able to list the '
+ 'stock moves assigned to picking 1.')
# User 2 cannot list the pickings 1
picking_ids =\
self.PickingObj.sudo(self.user2_id).\
From 4a74342f2df3cad5cdf9dcfab898e2df7b84d992 Mon Sep 17 00:00:00 2001
From: jbeficent
Date: Wed, 28 Sep 2016 14:35:37 +0200
Subject: [PATCH 04/49] flake 8
---
stock_operating_unit/model/stock.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 9a588839d2..7dcbc6e491 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -83,11 +83,10 @@ def _check_company_operating_unit(self):
def _check_parent_operating_unit(self):
for rec in self:
if (
- rec.location_id
- and rec.location_id.usage == 'internal'
- and rec.operating_unit_id
- and rec.operating_unit_id !=
- rec.location_id.operating_unit_id
+ rec.location_id and
+ rec.location_id.usage == 'internal' and
+ rec.operating_unit_id and
+ rec.operating_unit_id != rec.location_id.operating_unit_id
):
raise UserError(_('Configuration error!\nThe Parent\
Stock Location must belong to the same Operating Unit.'))
From 301ace70977023f4d2c735a5c6361bfc418c2f4e Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Fri, 30 Sep 2016 14:09:52 +0200
Subject: [PATCH 05/49] update contributors
---
stock_operating_unit/README.rst | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index 71be286e3b..387368885c 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -51,8 +51,9 @@ Images
Contributors
------------
-* Eficent
-* Serpent Consulting Services Pvt. Ltd.
+* Jordi Ballester Alomar
+* Aaron Henriquez
+* Sudhir Arya
Maintainer
----------
From ac0cf38c875e2672885d20dc1440ed912b7c9690 Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Tue, 4 Oct 2016 15:21:16 +0200
Subject: [PATCH 06/49] code style
---
stock_operating_unit/model/stock.py | 77 ++++++++++++++---------------
1 file changed, 38 insertions(+), 39 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 7dcbc6e491..bcca89425c 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -37,26 +37,23 @@ class StockLocation(models.Model):
def _check_warehouse_operating_unit(self):
for rec in self:
warehouse_obj = self.env['stock.warehouse']
- warehouse = warehouse_obj.search([('wh_input_stock_loc_id', 'in',
- rec.ids)])
- for w in warehouse:
+ warehouses = warehouse_obj.search(
+ ['|','|',('wh_input_stock_loc_id','=',rec.ids[0]),
+ ('lot_stock_id', 'in', rec.ids),
+ ('wh_output_stock_loc_id', 'in', rec.ids)])
+ for w in warehouses:
if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error!\nThis location is\
- assigned to a warehouse that belongs to a\
- different operating unit.'))
- warehouse = warehouse_obj.search([('lot_stock_id', 'in', rec.ids)])
- for w in warehouse:
+ raise UserError(_('Configuration error!\nThis location is '
+ 'assigned to a warehouse that belongs to'
+ ' a different operating unit.'))
if self.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error!\nThis location is\
- assigned to a warehouse that belongs to a\
- different operating unit.'))
- warehouse = warehouse_obj.search([('wh_output_stock_loc_id', 'in',
- rec.ids)])
- for w in warehouse:
+ raise UserError(_('Configuration error!\nThis location is '
+ 'assigned to a warehouse that belongs to'
+ ' a different operating unit.'))
if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error!\nThis location is\
- assigned to a warehouse that belongs to a different\
- operating unit.'))
+ raise UserError(_('Configuration error!\nThis location is'
+ ' assigned to a warehouse that belongs'
+ ' to a different operating unit.'))
@api.multi
@api.constrains('operating_unit_id')
@@ -110,28 +107,6 @@ def _check_company_operating_unit(self):
raise UserError(_('Configuration error!\nThe Company in the\
Stock Picking and in the Operating Unit must be the same.'))
- @api.multi
- @api.constrains('operating_unit_id', 'move_lines')
- def _check_stock_move_operating_unit(self):
- for rec in self:
- if not rec.operating_unit_id:
- return True
- operating_unit = rec.operating_unit_id
- for sm in rec.move_lines:
- if (
- sm.location_id and
- sm.location_id.operating_unit_id and
- operating_unit != sm.location_id.operating_unit_id
- ) and (
- sm.location_dest_id and
- sm.location_dest_id.operating_unit_id and
- operating_unit !=
- sm.location_dest_id.operating_unit_id
- ):
- raise UserError(_('Configuration error!\nThe Stock moves\
- must be related to a location (source or destination)\
- that belongs to the requesting Operating Unit.'))
-
class StockMove(models.Model):
_inherit = 'stock.move'
@@ -144,3 +119,27 @@ class StockMove(models.Model):
fields.Many2one('operating.unit',
related='location_dest_id.operating_unit_id',
string='Dest. Location Operating Unit', readonly=True)
+
+
+ @api.multi
+ @api.constrains('operating_unit_id', 'location_id',
+ 'operating_unit_dest_id', 'location_dest_id')
+ def _check_stock_move_operating_unit(self):
+ for stock_move in self:
+ if not stock_move.operating_unit_id:
+ return True
+ operating_unit = stock_move.operating_unit_id
+ if (
+ stock_move.location_id and
+ stock_move.location_id.operating_unit_id and
+ operating_unit != stock_move.location_id.
+ operating_unit_id
+ ) and (
+ stock_move.location_dest_id and
+ stock_move.location_dest_id.operating_unit_id and
+ operating_unit !=
+ stock_move.location_dest_id.operating_unit_id
+ ):
+ raise UserError(_('Configuration error!\nThe Stock moves\
+ must be related to a location (source or destination)\
+ that belongs to the requesting Operating Unit.'))
From 6f189ece142ca79af8fcb90af829adad8b414350 Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Tue, 4 Oct 2016 16:19:31 +0200
Subject: [PATCH 07/49] constraint that checks the OU in the picking matches
the one in the move
---
stock_operating_unit/model/stock.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index bcca89425c..b4190b981b 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -122,23 +122,26 @@ class StockMove(models.Model):
@api.multi
- @api.constrains('operating_unit_id', 'location_id',
+ @api.constrains('operating_unit_id', 'location_id', 'picking_id',
'operating_unit_dest_id', 'location_dest_id')
def _check_stock_move_operating_unit(self):
for stock_move in self:
if not stock_move.operating_unit_id:
return True
operating_unit = stock_move.operating_unit_id
+ operating_unit_dest = stock_move.operating_unit_dest_id
if (
stock_move.location_id and
stock_move.location_id.operating_unit_id and
- operating_unit != stock_move.location_id.
+ stock_move.picking_id and
+ operating_unit != stock_move.picking_id.
operating_unit_id
) and (
stock_move.location_dest_id and
stock_move.location_dest_id.operating_unit_id and
- operating_unit !=
- stock_move.location_dest_id.operating_unit_id
+ stock_move.picking_id and
+ operating_unit_dest !=
+ stock_move.picking_id.operating_unit_id
):
raise UserError(_('Configuration error!\nThe Stock moves\
must be related to a location (source or destination)\
From 31a594b1b1307909735a1be66d3d80f47b25f229 Mon Sep 17 00:00:00 2001
From: jbeficent
Date: Wed, 5 Oct 2016 17:16:13 +0200
Subject: [PATCH 08/49] the operating unit in pickings should derive from the
picking type
---
stock_operating_unit/model/stock.py | 32 +++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index b4190b981b..7a65500476 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -38,7 +38,7 @@ def _check_warehouse_operating_unit(self):
for rec in self:
warehouse_obj = self.env['stock.warehouse']
warehouses = warehouse_obj.search(
- ['|','|',('wh_input_stock_loc_id','=',rec.ids[0]),
+ ['|', '|', ('wh_input_stock_loc_id', '=', rec.ids[0]),
('lot_stock_id', 'in', rec.ids),
('wh_output_stock_loc_id', 'in', rec.ids)])
for w in warehouses:
@@ -93,10 +93,20 @@ class StockPicking(models.Model):
_inherit = 'stock.picking'
operating_unit_id = fields.Many2one('operating.unit',
- 'Requesting Operating Unit',
- default=lambda self:
- self.env['res.users'].
- operating_unit_default_get(self._uid))
+ 'Requesting Operating Unit')
+
+ @api.v7
+ def onchange_picking_type(self, cr, uid, ids, picking_type_id, partner_id,
+ context=None):
+ res = super(StockPicking, self).onchange_picking_type(
+ cr, uid, ids, picking_type_id, partner_id, context=context)
+ if picking_type_id:
+ picking_type = self.pool.get('stock.picking.type').browse(
+ cr, uid, picking_type_id, context=context) or None
+ res['value']['operating_unit_id'] = \
+ picking_type.warehouse_id.operating_unit_id and \
+ picking_type.warehouse_id.operating_unit_id.id or False
+ return res
@api.multi
@api.constrains('operating_unit_id', 'company_id')
@@ -107,6 +117,17 @@ def _check_company_operating_unit(self):
raise UserError(_('Configuration error!\nThe Company in the\
Stock Picking and in the Operating Unit must be the same.'))
+ @api.multi
+ @api.constrains('operating_unit_id', 'picking_type_id')
+ def _check_picking_type_operating_unit(self):
+ for rec in self:
+ if rec.picking_type_id and rec.operating_unit_id and \
+ rec.picking_type_id.warehouse_id.operating_unit_id != \
+ rec.operating_unit_id:
+ raise UserError(_('Configuration error!\nThe Operating Unit '
+ 'of the picking must be the same as that '
+ 'of the warehouse of the Picking Type.'))
+
class StockMove(models.Model):
_inherit = 'stock.move'
@@ -120,7 +141,6 @@ class StockMove(models.Model):
related='location_dest_id.operating_unit_id',
string='Dest. Location Operating Unit', readonly=True)
-
@api.multi
@api.constrains('operating_unit_id', 'location_id', 'picking_id',
'operating_unit_dest_id', 'location_dest_id')
From eb63282e28adf856d99fc7fdda9a0d3df5569ce2 Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Wed, 5 Oct 2016 17:52:10 +0200
Subject: [PATCH 09/49] travis issues
---
stock_operating_unit/model/stock.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 7a65500476..6412d68d89 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -151,17 +151,17 @@ def _check_stock_move_operating_unit(self):
operating_unit = stock_move.operating_unit_id
operating_unit_dest = stock_move.operating_unit_dest_id
if (
- stock_move.location_id and
- stock_move.location_id.operating_unit_id and
- stock_move.picking_id and
+ stock_move.location_id and
+ stock_move.location_id.operating_unit_id and
+ stock_move.picking_id and
operating_unit != stock_move.picking_id.
- operating_unit_id
+ operating_unit_id
) and (
- stock_move.location_dest_id and
- stock_move.location_dest_id.operating_unit_id and
+ stock_move.location_dest_id and
+ stock_move.location_dest_id.operating_unit_id and
stock_move.picking_id and
- operating_unit_dest !=
- stock_move.picking_id.operating_unit_id
+ operating_unit_dest !=
+ stock_move.picking_id.operating_unit_id
):
raise UserError(_('Configuration error!\nThe Stock moves\
must be related to a location (source or destination)\
From 1e32c3dba4af1928acc95764f0d73b8f6093c1c3 Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Fri, 4 Nov 2016 10:56:58 +0100
Subject: [PATCH 10/49] travis issues and test stock picking
---
stock_operating_unit/model/stock.py | 16 ++++++++--------
.../tests/test_stock_operating_unit.py | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 6412d68d89..0a3139393c 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -152,16 +152,16 @@ def _check_stock_move_operating_unit(self):
operating_unit_dest = stock_move.operating_unit_dest_id
if (
stock_move.location_id and
- stock_move.location_id.operating_unit_id and
- stock_move.picking_id and
- operating_unit != stock_move.picking_id.
- operating_unit_id
+ stock_move.location_id.operating_unit_id and
+ stock_move.picking_id and
+ operating_unit !=
+ stock_move.picking_id.operating_unit_id
) and (
stock_move.location_dest_id and
- stock_move.location_dest_id.operating_unit_id and
- stock_move.picking_id and
- operating_unit_dest !=
- stock_move.picking_id.operating_unit_id
+ stock_move.location_dest_id.operating_unit_id and
+ stock_move.picking_id and
+ operating_unit_dest !=
+ stock_move.picking_id.operating_unit_id
):
raise UserError(_('Configuration error!\nThe Stock moves\
must be related to a location (source or destination)\
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index 291ff1ab7c..895b0523f7 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -41,7 +41,7 @@ def setUp(self):
[self.b2c])
# Create Incoming Shipments
self.picking_in1 = self._create_picking(self.user1_id,
- self.ou1.id,
+ self.b2c.id,
self.b2c_type_in_id,
self.supplier_location,
self.stock_location)
From 5b92f84228029599931124a88430e62f1984829c Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Fri, 4 Nov 2016 11:55:54 +0100
Subject: [PATCH 11/49] test stock security according picking 1 in
test_stock_picking
---
stock_operating_unit/tests/test_stock_security.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index 20c2595eef..f2a87e78e4 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -59,9 +59,9 @@ def test_stock_ou_security(self):
search([('picking_id', '=', self.picking_in1.id)]).ids
self.assertEqual(move_ids, [], 'User 2 should not be able to list the '
'stock moves assigned to picking 1.')
- # User 2 cannot list the pickings 1
+ # User 2 can list the picking 1
picking_ids =\
self.PickingObj.sudo(self.user2_id).\
search([('id', '=', self.picking_in1.id)]).ids
- self.assertEqual(picking_ids, [], 'User 2 should not be able to list'
+ self.assertEqual(len(picking_ids), 1, 'User 2 should be able to list'
'the picking 1.')
From 902e962b94cfc68700132f880968f331ac7462e7 Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Mon, 16 Jan 2017 17:47:41 +0100
Subject: [PATCH 12/49] Update operating units of previous locations
---
stock_operating_unit/__init__.py | 1 +
stock_operating_unit/__openerp__.py | 1 +
stock_operating_unit/hooks.py | 20 ++++++++++++++++++++
3 files changed, 22 insertions(+)
create mode 100644 stock_operating_unit/hooks.py
diff --git a/stock_operating_unit/__init__.py b/stock_operating_unit/__init__.py
index 54776d1e38..0bb5c16af1 100644
--- a/stock_operating_unit/__init__.py
+++ b/stock_operating_unit/__init__.py
@@ -3,3 +3,4 @@
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import model
+from .hooks import update_operating_unit_location
diff --git a/stock_operating_unit/__openerp__.py b/stock_operating_unit/__openerp__.py
index c861ba0f9c..e9553966d2 100644
--- a/stock_operating_unit/__openerp__.py
+++ b/stock_operating_unit/__openerp__.py
@@ -23,4 +23,5 @@
"demo/stock_demo.xml",
],
"installable": True,
+ "post_init_hook": "update_operating_unit_location",
}
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
new file mode 100644
index 0000000000..76566224d8
--- /dev/null
+++ b/stock_operating_unit/hooks.py
@@ -0,0 +1,20 @@
+# -*- 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 SUPERUSER_ID
+from openerp.api import Environment
+
+def update_operating_unit_location(cr, registry):
+ env = Environment(cr, SUPERUSER_ID, {})
+ warehouses = env['stock.warehouse'].search([])
+ for warehouse in warehouses:
+ operating_unit = warehouse.operating_unit_id
+ parent_location = warehouse.view_location_id
+ locations = env['stock.location'].search(
+ [('id', 'child_of', [parent_location.id]),
+ ('usage', '=', 'internal')])
+ for location in locations:
+ if operating_unit:
+ location.write({'operating_unit_id': operating_unit.id})
+ return True
From 780dc1deeccc39f23ddaf90cab6f84b18cf3027f Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Tue, 17 Jan 2017 10:01:19 +0100
Subject: [PATCH 13/49] lint check operating_unit_id readonly in the picking
---
stock_operating_unit/hooks.py | 3 ++-
stock_operating_unit/model/stock.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
index 76566224d8..1239564667 100644
--- a/stock_operating_unit/hooks.py
+++ b/stock_operating_unit/hooks.py
@@ -5,6 +5,7 @@
from openerp import SUPERUSER_ID
from openerp.api import Environment
+
def update_operating_unit_location(cr, registry):
env = Environment(cr, SUPERUSER_ID, {})
warehouses = env['stock.warehouse'].search([])
@@ -13,7 +14,7 @@ def update_operating_unit_location(cr, registry):
parent_location = warehouse.view_location_id
locations = env['stock.location'].search(
[('id', 'child_of', [parent_location.id]),
- ('usage', '=', 'internal')])
+ ('usage', '=', 'internal')])
for location in locations:
if operating_unit:
location.write({'operating_unit_id': operating_unit.id})
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 0a3139393c..8ec10c4e0b 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -93,7 +93,8 @@ class StockPicking(models.Model):
_inherit = 'stock.picking'
operating_unit_id = fields.Many2one('operating.unit',
- 'Requesting Operating Unit')
+ 'Requesting Operating Unit',
+ readonly=1)
@api.v7
def onchange_picking_type(self, cr, uid, ids, picking_type_id, partner_id,
From 9a7f22e8061f707d1c4a5bb26099c5488562367b Mon Sep 17 00:00:00 2001
From: Guewen Baconnier
Date: Mon, 23 Jan 2017 11:06:22 +0100
Subject: [PATCH 14/49] Correct error message and xml files
* Replace and elements by
* Remove spaces in strings introduced because of \
* Remove exclamation points in error messages
* Remove most of the \ where it can be replaced by parenthesis
---
stock_operating_unit/__openerp__.py | 4 +-
stock_operating_unit/data/stock_data.xml | 18 +-
stock_operating_unit/demo/stock_demo.xml | 110 ++++---
stock_operating_unit/model/stock.py | 134 +++++----
.../security/stock_security.xml | 110 ++++---
stock_operating_unit/view/stock.xml | 284 +++++++++---------
6 files changed, 333 insertions(+), 327 deletions(-)
diff --git a/stock_operating_unit/__openerp__.py b/stock_operating_unit/__openerp__.py
index e9553966d2..c6bffd06a5 100644
--- a/stock_operating_unit/__openerp__.py
+++ b/stock_operating_unit/__openerp__.py
@@ -5,8 +5,8 @@
{
"name": "Stock with Operating Units",
- "summary": "An operating unit (OU) is an organizational entity part of a\
- company",
+ "summary": "An operating unit (OU) is an organizational entity part of a "
+ "company",
"version": "9.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent, Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/data/stock_data.xml b/stock_operating_unit/data/stock_data.xml
index 7229f533bc..11638e3b88 100644
--- a/stock_operating_unit/data/stock_data.xml
+++ b/stock_operating_unit/data/stock_data.xml
@@ -1,14 +1,12 @@
-
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
diff --git a/stock_operating_unit/demo/stock_demo.xml b/stock_operating_unit/demo/stock_demo.xml
index 40dbb9cca9..b82736abea 100644
--- a/stock_operating_unit/demo/stock_demo.xml
+++ b/stock_operating_unit/demo/stock_demo.xml
@@ -1,57 +1,55 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Your company child
-
-
-
- Chicago
- CH
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- B2B Warehouse
- B2B
-
-
-
-
-
-
-
- B2C Warehouse
- B2C
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Your company child
+
+
+
+ Chicago
+ CH
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ B2B Warehouse
+ B2B
+
+
+
+
+
+
+
+ B2C Warehouse
+ B2C
+
+
+
+
+
+
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 8ec10c4e0b..c8700090a3 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -2,28 +2,30 @@
# © 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.tools.translate import _
-from openerp import api, fields, models
-from openerp.exceptions import Warning as UserError
+from openerp import _, api, fields, models
+from openerp.exceptions import UserError
class StockWarehouse(models.Model):
_inherit = "stock.warehouse"
- operating_unit_id = fields.Many2one('operating.unit',
- 'Operating Unit',
- default=lambda self:
- self.env['res.users'].
- operating_unit_default_get(self._uid))
+ operating_unit_id = fields.Many2one(
+ comodel_name='operating.unit',
+ string='Operating Unit',
+ default=lambda self: (self.env['res.users'].
+ operating_unit_default_get(self.env.uid))
+ )
@api.multi
@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:
- raise UserError(_('Configuration error!\nThe Company in the\
- Stock Warehouse and in the Operating Unit must be the same.'))
+ 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 Stock Warehouse'
+ ' and in the Operating Unit must be the same.')
+ )
class StockLocation(models.Model):
@@ -43,15 +45,15 @@ def _check_warehouse_operating_unit(self):
('wh_output_stock_loc_id', 'in', rec.ids)])
for w in warehouses:
if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error!\nThis location is '
+ raise UserError(_('Configuration error\nThis location is '
'assigned to a warehouse that belongs to'
' a different operating unit.'))
if self.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error!\nThis location is '
+ raise UserError(_('Configuration error\nThis location is '
'assigned to a warehouse that belongs to'
' a different operating unit.'))
if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error!\nThis location is'
+ raise UserError(_('Configuration error\nThis location is'
' assigned to a warehouse that belongs'
' to a different operating unit.'))
@@ -60,20 +62,25 @@ def _check_warehouse_operating_unit(self):
def _check_required_operating_unit(self):
for rec in self:
if rec.usage == 'internal' and not rec.operating_unit_id:
- raise UserError(_('Configuration error!\nThe operating unit\
- should be assigned to internal locations and to non other.'))
+ raise UserError(
+ _('Configuration error\nThe operating unit should be '
+ 'assigned to internal locations and to non other.')
+ )
if rec.usage != 'internal' and rec.operating_unit_id:
- raise UserError(_('Configuration error!\nThe operating unit\
- should be assigned to internal locations and to non other.'))
+ raise UserError(
+ _('Configuration error\nThe operating unit should be '
+ 'assigned to internal locations and to non other.')
+ )
@api.multi
@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:
- raise UserError(_('Configuration error!\nThe Company in the\
- Stock Location and in the Operating Unit must be the same.'))
+ 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 Stock Location '
+ 'and in the Operating Unit must be the same.'))
@api.multi
@api.constrains('operating_unit_id', 'location_id')
@@ -85,8 +92,10 @@ def _check_parent_operating_unit(self):
rec.operating_unit_id and
rec.operating_unit_id != rec.location_id.operating_unit_id
):
- raise UserError(_('Configuration error!\nThe Parent\
- Stock Location must belong to the same Operating Unit.'))
+ raise UserError(
+ _('Configuration error\nThe Parent Stock Location '
+ 'must belong to the same Operating Unit.')
+ )
class StockPicking(models.Model):
@@ -102,45 +111,51 @@ def onchange_picking_type(self, cr, uid, ids, picking_type_id, partner_id,
res = super(StockPicking, self).onchange_picking_type(
cr, uid, ids, picking_type_id, partner_id, context=context)
if picking_type_id:
- picking_type = self.pool.get('stock.picking.type').browse(
+ picking_type = self.pool['stock.picking.type'].browse(
cr, uid, picking_type_id, context=context) or None
- res['value']['operating_unit_id'] = \
- picking_type.warehouse_id.operating_unit_id and \
- picking_type.warehouse_id.operating_unit_id.id or False
+ unit = picking_type.warehouse_id.operating_unit_id
+ if unit:
+ res['value']['operating_unit_id'] = unit.id
return res
@api.multi
@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:
- raise UserError(_('Configuration error!\nThe Company in the\
- Stock Picking and in the Operating Unit must be the same.'))
+ 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 Stock Picking '
+ 'and in the Operating Unit must be the same.')
+ )
@api.multi
@api.constrains('operating_unit_id', 'picking_type_id')
def _check_picking_type_operating_unit(self):
for rec in self:
- if rec.picking_type_id and rec.operating_unit_id and \
- rec.picking_type_id.warehouse_id.operating_unit_id != \
- rec.operating_unit_id:
- raise UserError(_('Configuration error!\nThe Operating Unit '
- 'of the picking must be the same as that '
- 'of the warehouse of the Picking Type.'))
+ warehouse = rec.picking_type_id.warehouse_id
+ if (rec.picking_type_id and rec.operating_unit_id and
+ warehouse.operating_unit_id != rec.operating_unit_id):
+ raise UserError(
+ _('Configuration error\nThe Operating Unit of the picking '
+ 'must be the same as that of the warehouse of the '
+ 'Picking Type.')
+ )
class StockMove(models.Model):
_inherit = 'stock.move'
- operating_unit_id =\
- fields.Many2one('operating.unit',
- related='location_id.operating_unit_id',
- string='Source Location Operating Unit', readonly=True)
- operating_unit_dest_id =\
- fields.Many2one('operating.unit',
- related='location_dest_id.operating_unit_id',
- string='Dest. Location Operating Unit', readonly=True)
+ operating_unit_id = fields.Many2one(
+ related='location_id.operating_unit_id',
+ string='Source Location Operating Unit',
+ readonly=True,
+ )
+ operating_unit_dest_id = fields.Many2one(
+ related='location_dest_id.operating_unit_id',
+ string='Dest. Location Operating Unit',
+ readonly=True,
+ )
@api.multi
@api.constrains('operating_unit_id', 'location_id', 'picking_id',
@@ -151,19 +166,18 @@ def _check_stock_move_operating_unit(self):
return True
operating_unit = stock_move.operating_unit_id
operating_unit_dest = stock_move.operating_unit_dest_id
- if (
- stock_move.location_id and
+ if (stock_move.location_id and
stock_move.location_id.operating_unit_id and
stock_move.picking_id and
- operating_unit !=
- stock_move.picking_id.operating_unit_id
- ) and (
- stock_move.location_dest_id and
- stock_move.location_dest_id.operating_unit_id and
- stock_move.picking_id and
- operating_unit_dest !=
- stock_move.picking_id.operating_unit_id
+ operating_unit != stock_move.picking_id.operating_unit_id
+ ) and (
+ stock_move.location_dest_id and
+ stock_move.location_dest_id.operating_unit_id and
+ stock_move.picking_id and
+ operating_unit_dest != stock_move.picking_id.operating_unit_id
):
- raise UserError(_('Configuration error!\nThe Stock moves\
- must be related to a location (source or destination)\
- that belongs to the requesting Operating Unit.'))
+ raise UserError(
+ _('Configuration error\nThe Stock moves must '
+ 'be related to a location (source or destination) '
+ 'that belongs to the requesting Operating Unit.')
+ )
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index 80b9fd1c3c..f6fc3a9cfc 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -1,63 +1,61 @@
-
-
+
-
-
- ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
- Warehouses from allowed operating units
-
-
-
-
-
-
+
+
+ ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Warehouses from allowed operating units
+
+
+
+
+
+
-
-
- ['|',('warehouse_id.operating_unit_id','=',False),('warehouse_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
- Stock Picking Type from allowed operating units
-
-
-
-
-
-
+
+
+ ['|',('warehouse_id.operating_unit_id','=',False),('warehouse_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Stock Picking Type from allowed operating units
+
+
+
+
+
+
-
-
- ['|', ('operating_unit_id','in',[g.id for g
- in user.operating_unit_ids]), ('operating_unit_id','=', False)]
- Stock locations from allowed operating units
-
-
-
-
-
-
+
+
+ ['|', ('operating_unit_id','in',[g.id for g
+ in user.operating_unit_ids]), ('operating_unit_id','=', False)]
+ Stock locations from allowed operating units
+
+
+
+
+
+
-
-
- ['|',('location_id.operating_unit_id','=',False),('location_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids]),
- '|',('location_dest_id.operating_unit_id','=',False),('location_dest_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
- Stock moves from allowed operating units
-
-
-
-
-
-
+
+
+ ['|',('location_id.operating_unit_id','=',False),('location_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids]),
+ '|',('location_dest_id.operating_unit_id','=',False),('location_dest_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Stock moves from allowed operating units
+
+
+
+
+
+
-
-
- ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
- Stock pickings from allowed operating units
-
-
-
-
-
-
+
+
+ ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ Stock pickings from allowed operating units
+
+
+
+
+
+
-
-
+
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index 462c611953..54bf6c0097 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -1,158 +1,156 @@
-
-
+
-
- stock.warehouse
- stock.warehouse
-
-
-
-
-
-
-
+
+ stock.warehouse
+ stock.warehouse
+
+
+
+
+
+
+
-
- stock.warehouse.tree
- stock.warehouse
-
-
-
-
-
-
-
+
+ stock.warehouse.tree
+ stock.warehouse
+
+
+
+
+
+
+
-
- stock.location.form
- stock.location
-
-
-
-
-
-
-
+
+ stock.location.form
+ stock.location
+
+
+
+
+
+
+
-
- stock.location.tree
- stock.location
-
-
-
-
-
-
-
+
+ stock.location.tree
+ stock.location
+
+
+
+
+
+
+
-
- stock.location.search
- stock.location
-
-
-
-
-
-
-
+
+ stock.location.search
+ stock.location
+
+
+
+
+
+
+
-
- stock.picking.tree
- stock.picking
-
-
-
-
-
-
-
+
+ stock.picking.tree
+ stock.picking
+
+
+
+
+
+
+
-
- stock.picking.form
- stock.picking
-
-
-
-
-
-
-
+
+ stock.picking.form
+ stock.picking
+
+
+
+
+
+
+
-
- stock.picking.internal.search
- stock.picking
-
-
-
-
-
-
-
-
+
+ stock.picking.internal.search
+ stock.picking
+
+
+
+
-
+
+
+
+
+
-
- stock.move.tree
- stock.move
-
-
-
-
-
-
-
-
-
-
+
+ stock.move.tree
+ stock.move
+
+
+
+
+
+
+
+
+
+
-
- stock.move.tree
- stock.move
-
-
-
-
-
-
-
-
-
-
+
+ stock.move.tree
+ stock.move
+
+
+
+
+
+
+
+
+
+
-
- Stock Moves
- stock.move
- move_history_ids
-
-
-
-
-
-
-
-
-
-
+
+ Stock Moves
+ stock.move
+ move_history_ids
+
+
+
+
+
+
+
+
+
+
-
- stock.move.form
- stock.move
-
-
-
-
-
-
-
-
-
-
+
+ stock.move.form
+ stock.move
+
+
+
+
+
+
+
+
+
+
-
-
+
From 90946144eed9d99ced84c198f1a99e11559de26a Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Thu, 26 Jan 2017 14:51:00 +0100
Subject: [PATCH 15/49] [MIG] stock_operating_unit to v10.0
---
stock_operating_unit/README.rst | 2 +-
stock_operating_unit/__init__.py | 4 +-
.../{__openerp__.py => __manifest__.py} | 9 +++--
stock_operating_unit/data/stock_data.xml | 3 ++
stock_operating_unit/demo/stock_demo.xml | 5 ++-
stock_operating_unit/hooks.py | 4 +-
stock_operating_unit/model/__init__.py | 4 +-
stock_operating_unit/model/stock.py | 38 +++++++++++--------
.../security/stock_security.xml | 4 +-
stock_operating_unit/tests/__init__.py | 4 +-
.../tests/test_stock_operating_unit.py | 4 +-
.../tests/test_stock_picking.py | 4 +-
.../tests/test_stock_security.py | 4 +-
stock_operating_unit/view/stock.xml | 4 +-
14 files changed, 56 insertions(+), 37 deletions(-)
rename stock_operating_unit/{__openerp__.py => __manifest__.py} (75%)
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index 387368885c..180248a453 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -29,7 +29,7 @@ Other modules extend the standard Odoo apps with the OU.
.. 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
Bug Tracker
===========
diff --git a/stock_operating_unit/__init__.py b/stock_operating_unit/__init__.py
index 0bb5c16af1..44392c204f 100644
--- a/stock_operating_unit/__init__.py
+++ b/stock_operating_unit/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import model
from .hooks import update_operating_unit_location
diff --git a/stock_operating_unit/__openerp__.py b/stock_operating_unit/__manifest__.py
similarity index 75%
rename from stock_operating_unit/__openerp__.py
rename to stock_operating_unit/__manifest__.py
index c6bffd06a5..f1218b8781 100644
--- a/stock_operating_unit/__openerp__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Stock with Operating Units",
"summary": "An operating unit (OU) is an organizational entity part of a "
"company",
- "version": "9.0.1.0.0",
+ "version": "10.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
- "author": "Eficent, Serpent Consulting Services Pvt. Ltd., "
+ "author": "Eficent, "
+ "Serpent Consulting Services Pvt. Ltd., "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "http://www.eficent.com",
diff --git a/stock_operating_unit/data/stock_data.xml b/stock_operating_unit/data/stock_data.xml
index 11638e3b88..ab3f36c1b8 100644
--- a/stock_operating_unit/data/stock_data.xml
+++ b/stock_operating_unit/data/stock_data.xml
@@ -1,4 +1,7 @@
+
diff --git a/stock_operating_unit/demo/stock_demo.xml b/stock_operating_unit/demo/stock_demo.xml
index b82736abea..ceed68b222 100644
--- a/stock_operating_unit/demo/stock_demo.xml
+++ b/stock_operating_unit/demo/stock_demo.xml
@@ -1,4 +1,7 @@
+
@@ -26,7 +29,7 @@
-
+
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
index 1239564667..7b9a5791e4 100644
--- a/stock_operating_unit/hooks.py
+++ b/stock_operating_unit/hooks.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from openerp import SUPERUSER_ID
from openerp.api import Environment
diff --git a/stock_operating_unit/model/__init__.py b/stock_operating_unit/model/__init__.py
index a05fa0038b..a73fea253c 100644
--- a/stock_operating_unit/model/__init__.py
+++ b/stock_operating_unit/model/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import stock
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index c8700090a3..5cdd09ec9d 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 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
@@ -9,11 +9,20 @@
class StockWarehouse(models.Model):
_inherit = "stock.warehouse"
+ def _default_operating_unit(self):
+ if self.company_id:
+ company = self.company_id
+ else:
+ company = self.env['res.company']._company_default_get(
+ 'stock.inventory')
+ for ou in self.env.user.operating_unit_ids:
+ if company == self.company_id:
+ self.operating_unit_id = ou
+
operating_unit_id = fields.Many2one(
comodel_name='operating.unit',
string='Operating Unit',
- default=lambda self: (self.env['res.users'].
- operating_unit_default_get(self.env.uid))
+ default=_default_operating_unit
)
@api.multi
@@ -105,17 +114,16 @@ class StockPicking(models.Model):
'Requesting Operating Unit',
readonly=1)
- @api.v7
- def onchange_picking_type(self, cr, uid, ids, picking_type_id, partner_id,
- context=None):
- res = super(StockPicking, self).onchange_picking_type(
- cr, uid, ids, picking_type_id, partner_id, context=context)
- if picking_type_id:
- picking_type = self.pool['stock.picking.type'].browse(
- cr, uid, picking_type_id, context=context) or None
- unit = picking_type.warehouse_id.operating_unit_id
- if unit:
- res['value']['operating_unit_id'] = unit.id
+ @api.onchange('picking_type_id', 'partner_id')
+ def onchange_picking_type(self):
+ res = super(StockPicking, self).onchange_picking_type()
+ if self.picking_type_id:
+ picking_type = self.env['stock.picking.type'].browse(
+ self.picking_type_id.id) or None
+ if picking_type:
+ unit = picking_type.warehouse_id.operating_unit_id
+ if unit:
+ res['value']['operating_unit_id'] = unit.id
return res
@api.multi
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index f6fc3a9cfc..5f5e829d32 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -1,6 +1,8 @@
+
-
['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
diff --git a/stock_operating_unit/tests/__init__.py b/stock_operating_unit/tests/__init__.py
index 4101fcef9f..2aacf0c00a 100644
--- a/stock_operating_unit/tests/__init__.py
+++ b/stock_operating_unit/tests/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
-# © 2015 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
# - Jordi Ballester Alomar
-# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_operating_unit
from . import test_stock_picking
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index 895b0523f7..61c0549d06 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from openerp.addons.stock.tests import common
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
index 7d0298067c..29ff52b82c 100644
--- a/stock_operating_unit/tests/test_stock_picking.py
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_operating_unit as test_stock_ou
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index f2a87e78e4..61001a4704 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# © 2016 Eficent Business and IT Consulting Services S.L.
-# © 2016 Serpent Consulting Services Pvt. Ltd.
+# © 2016-2017 Eficent Business and IT Consulting Services S.L.
+# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_operating_unit as test_stock_ou
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index 54bf6c0097..ecfbbd9094 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -1,6 +1,8 @@
+
-
stock.warehouse
stock.warehouse
From 2d5f4f643b34fa9afedf78908084b6544ec44eca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esther=20Mart=C3=ADn?=
Date: Wed, 5 Apr 2017 11:39:11 +0200
Subject: [PATCH 16/49] [FIX] stock_operating_unit: correct constrain function,
avoid error on pickings
---
stock_operating_unit/model/stock.py | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 5cdd09ec9d..35c09b0169 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -57,7 +57,7 @@ def _check_warehouse_operating_unit(self):
raise UserError(_('Configuration error\nThis location is '
'assigned to a warehouse that belongs to'
' a different operating unit.'))
- if self.operating_unit_id != w.operating_unit_id:
+ if rec.operating_unit_id != w.operating_unit_id:
raise UserError(_('Configuration error\nThis location is '
'assigned to a warehouse that belongs to'
' a different operating unit.'))
@@ -118,12 +118,8 @@ class StockPicking(models.Model):
def onchange_picking_type(self):
res = super(StockPicking, self).onchange_picking_type()
if self.picking_type_id:
- picking_type = self.env['stock.picking.type'].browse(
- self.picking_type_id.id) or None
- if picking_type:
- unit = picking_type.warehouse_id.operating_unit_id
- if unit:
- res['value']['operating_unit_id'] = unit.id
+ unit = self.picking_type_id.warehouse_id.operating_unit_id
+ self.operating_unit_id = unit
return res
@api.multi
From f1fb689ab7a0c166d7c2d10e18e8bacfc16ff497 Mon Sep 17 00:00:00 2001
From: aheficent
Date: Thu, 28 Sep 2017 13:05:03 +0200
Subject: [PATCH 17/49] [FIX]onchange does not work with readonly fields
---
stock_operating_unit/__manifest__.py | 2 +-
stock_operating_unit/model/stock.py | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index f1218b8781..34875f4855 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -7,7 +7,7 @@
"name": "Stock with Operating Units",
"summary": "An operating unit (OU) is an organizational entity part of a "
"company",
- "version": "10.0.1.0.0",
+ "version": "10.0.1.0.1",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent, "
"Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 35c09b0169..fd28956e84 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -111,8 +111,7 @@ class StockPicking(models.Model):
_inherit = 'stock.picking'
operating_unit_id = fields.Many2one('operating.unit',
- 'Requesting Operating Unit',
- readonly=1)
+ 'Requesting Operating Unit')
@api.onchange('picking_type_id', 'partner_id')
def onchange_picking_type(self):
From 7a26ae9c1abc229dc6f95b161969595e5213fe1e Mon Sep 17 00:00:00 2001
From: aheficent
Date: Tue, 10 Apr 2018 12:33:30 +0200
Subject: [PATCH 18/49] [FIX]stock.move._check_stock_move_operating_unit
---
stock_operating_unit/model/stock.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index fd28956e84..5f3434ec35 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -161,8 +161,9 @@ class StockMove(models.Model):
)
@api.multi
- @api.constrains('operating_unit_id', 'location_id', 'picking_id',
- 'operating_unit_dest_id', 'location_dest_id')
+ @api.constrains('location_id.operating_unit_id', 'picking_id',
+ 'location_id', 'location_dest_id.operating_unit_id',
+ 'location_dest_id')
def _check_stock_move_operating_unit(self):
for stock_move in self:
if not stock_move.operating_unit_id:
From b1b24e2a16676419d92a32de1682d1dd7cced123 Mon Sep 17 00:00:00 2001
From: aaron
Date: Thu, 7 Jun 2018 10:53:31 +0200
Subject: [PATCH 19/49] [FIX]internal locations should consider all locations
but customer or suppliers
---
stock_operating_unit/model/stock.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index 5f3434ec35..aa5205559f 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -70,14 +70,15 @@ def _check_warehouse_operating_unit(self):
@api.constrains('operating_unit_id')
def _check_required_operating_unit(self):
for rec in self:
- if rec.usage == 'internal' and not rec.operating_unit_id:
+ if (rec.usage not in ('supplier', 'customer') and not
+ rec.operating_unit_id):
raise UserError(
- _('Configuration error\nThe operating unit should be '
+ _('Configuration error. The operating unit should be '
'assigned to internal locations and to non other.')
)
- if rec.usage != 'internal' and rec.operating_unit_id:
+ if rec.usage in ('supplier', 'customer') and rec.operating_unit_id:
raise UserError(
- _('Configuration error\nThe operating unit should be '
+ _('Configuration error. The operating unit should be '
'assigned to internal locations and to non other.')
)
From 0c4d1c1d9fff68df0567f14281f764eeb557f252 Mon Sep 17 00:00:00 2001
From: aheficent
Date: Thu, 26 Jul 2018 17:26:11 +0200
Subject: [PATCH 20/49] [FIX]field that triggers constraint is not a valid
field name
---
stock_operating_unit/model/stock.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
index aa5205559f..10d30075fe 100644
--- a/stock_operating_unit/model/stock.py
+++ b/stock_operating_unit/model/stock.py
@@ -162,8 +162,8 @@ class StockMove(models.Model):
)
@api.multi
- @api.constrains('location_id.operating_unit_id', 'picking_id',
- 'location_id', 'location_dest_id.operating_unit_id',
+ @api.constrains('operating_unit_id', 'picking_id',
+ 'location_id', 'operating_unit_dest_id',
'location_dest_id')
def _check_stock_move_operating_unit(self):
for stock_move in self:
From 40cb031c88bc55f33d41c32fafcc03478ec5a4e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Be=C3=B1at=20Jimenez?=
Date: Wed, 12 Dec 2018 12:36:20 +0100
Subject: [PATCH 21/49] [MIG] stock_operating_unit: Migration to v12
---
stock_operating_unit/README.rst | 73 ++-
stock_operating_unit/__init__.py | 4 +-
stock_operating_unit/__manifest__.py | 12 +-
stock_operating_unit/data/stock_data.xml | 4 +-
stock_operating_unit/demo/stock_demo.xml | 4 +-
stock_operating_unit/hooks.py | 17 +-
.../i18n/stock_operating_unit.pot | 123 +++++
stock_operating_unit/model/__init__.py | 10 +-
stock_operating_unit/model/stock.py | 188 --------
stock_operating_unit/model/stock_location.py | 67 +++
stock_operating_unit/model/stock_move.py | 42 ++
stock_operating_unit/model/stock_picking.py | 47 ++
stock_operating_unit/model/stock_rule.py | 14 +
stock_operating_unit/model/stock_warehouse.py | 52 ++
stock_operating_unit/readme/CONFIGURE.rst | 4 +
stock_operating_unit/readme/CONTRIBUTORS.rst | 3 +
stock_operating_unit/readme/DESCRIPTION.rst | 6 +
stock_operating_unit/readme/ROADMAP.rst | 3 +
stock_operating_unit/readme/USAGE.rst | 2 +
.../security/stock_security.xml | 49 +-
.../static/description/index.html | 450 ++++++++++++++++++
stock_operating_unit/tests/__init__.py | 5 +-
.../tests/test_stock_operating_unit.py | 7 +-
.../tests/test_stock_picking.py | 5 +-
.../tests/test_stock_security.py | 5 +-
stock_operating_unit/view/stock.xml | 158 ++++--
26 files changed, 1044 insertions(+), 310 deletions(-)
create mode 100644 stock_operating_unit/i18n/stock_operating_unit.pot
delete mode 100644 stock_operating_unit/model/stock.py
create mode 100644 stock_operating_unit/model/stock_location.py
create mode 100644 stock_operating_unit/model/stock_move.py
create mode 100644 stock_operating_unit/model/stock_picking.py
create mode 100644 stock_operating_unit/model/stock_rule.py
create mode 100644 stock_operating_unit/model/stock_warehouse.py
create mode 100644 stock_operating_unit/readme/CONFIGURE.rst
create mode 100644 stock_operating_unit/readme/CONTRIBUTORS.rst
create mode 100644 stock_operating_unit/readme/DESCRIPTION.rst
create mode 100644 stock_operating_unit/readme/ROADMAP.rst
create mode 100644 stock_operating_unit/readme/USAGE.rst
create mode 100644 stock_operating_unit/static/description/index.html
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index 180248a453..ef0c9a5939 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -1,17 +1,41 @@
-.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg
- :target: https://www.gnu.org/licenses/lgpl.html
- :alt: License: LGPL-3
-
==========================
Stock with Operating Units
==========================
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
+ :target: https://odoo-community.org/page/development-status
+ :alt: Beta
+.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ :alt: License: LGPL-3
+.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
+ :target: https://github.com/OCA/operating-unit/tree/12.0/stock_operating_unit
+ :alt: OCA/operating-unit
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-stock_operating_unit
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/213/12.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
This module introduces the following features:
+
- Adds the operating unit to the Warehouse.
- Adds the operating unit to the Stock Location.
- Adds the requesting operating unit to stock pickings.
- Implements user's security access rules.
+**Table of contents**
+
+.. contents::
+ :local:
Configuration
=============
@@ -27,45 +51,52 @@ Usage
This module defines the operating unit entity and the user's security rules.
Other modules extend the standard Odoo apps with the OU.
-.. 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
+Known issues / Roadmap
+======================
+
+The Manager can see the stock rules of other Operating Units but he can not
+edit them. If he tries to access to one of these stock rules, he will receive
+a configuration error.
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.
+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 `_.
+Do not contact contributors directly about support or help with technical issues.
Credits
=======
-Images
-------
+Authors
+~~~~~~~
-* Odoo Community Association: `Icon `_.
+* Eficent
+* Serpent Consulting Services Pvt. Ltd.
Contributors
-------------
+~~~~~~~~~~~~
* Jordi Ballester Alomar
* Aaron Henriquez
* Sudhir Arya
-Maintainer
-----------
+Maintainers
+~~~~~~~~~~~
+
+This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
- :target: http://odoo-community.org
-
-This module is maintained by the OCA.
+ :target: https://odoo-community.org
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.
+This module is part of the `OCA/operating-unit `_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_operating_unit/__init__.py b/stock_operating_unit/__init__.py
index 44392c204f..122296e393 100644
--- a/stock_operating_unit/__init__.py
+++ b/stock_operating_unit/__init__.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
+
from . import model
from .hooks import update_operating_unit_location
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index 34875f4855..242f1a5fa1 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -1,19 +1,17 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Stock with Operating Units",
- "summary": "An operating unit (OU) is an organizational entity part of a "
- "company",
- "version": "10.0.1.0.1",
+ "summary": "Adds the concept of operating unit (OU) in stock management",
+ "version": "12.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent, "
"Serpent Consulting Services Pvt. Ltd., "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
- "website": "http://www.eficent.com",
+ "website": "https://github.com/OCA/operating-unit",
"depends": ["stock", "account_operating_unit"],
"data": [
"security/stock_security.xml",
diff --git a/stock_operating_unit/data/stock_data.xml b/stock_operating_unit/data/stock_data.xml
index ab3f36c1b8..9b40fabd0f 100644
--- a/stock_operating_unit/data/stock_data.xml
+++ b/stock_operating_unit/data/stock_data.xml
@@ -1,6 +1,6 @@
-
diff --git a/stock_operating_unit/demo/stock_demo.xml b/stock_operating_unit/demo/stock_demo.xml
index ceed68b222..ca255a9a16 100644
--- a/stock_operating_unit/demo/stock_demo.xml
+++ b/stock_operating_unit/demo/stock_demo.xml
@@ -1,6 +1,6 @@
-
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
index 7b9a5791e4..7b66a21a45 100644
--- a/stock_operating_unit/hooks.py
+++ b/stock_operating_unit/hooks.py
@@ -1,9 +1,8 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
-from openerp import SUPERUSER_ID
-from openerp.api import Environment
+from odoo import SUPERUSER_ID
+from odoo.api import Environment
def update_operating_unit_location(cr, registry):
@@ -15,7 +14,9 @@ def update_operating_unit_location(cr, registry):
locations = env['stock.location'].search(
[('id', 'child_of', [parent_location.id]),
('usage', '=', 'internal')])
- for location in locations:
- if operating_unit:
- location.write({'operating_unit_id': operating_unit.id})
+ if operating_unit:
+ query = '''update stock_location set operating_unit_id = %s where
+ location_id in %s or id in %s'''
+ cr.execute(query, (operating_unit.id, tuple(locations.ids),
+ tuple(locations.ids)))
return True
diff --git a/stock_operating_unit/i18n/stock_operating_unit.pot b/stock_operating_unit/i18n/stock_operating_unit.pot
new file mode 100644
index 0000000000..0705b99dff
--- /dev/null
+++ b/stock_operating_unit/i18n/stock_operating_unit.pot
@@ -0,0 +1,123 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * stock_operating_unit
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_warehouse.py:50
+#, python-format
+msgid "Configuration Error. The Operating Unit of the Warehouse and the Location must be the same. "
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:51
+#, python-format
+msgid "Configuration error. The Company in the Stock Location and in the Operating Unit must be the same."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_picking.py:32
+#, python-format
+msgid "Configuration error. The Company in the Stock Picking and in the Operating Unit must be the same."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_warehouse.py:34
+#, python-format
+msgid "Configuration error. The Company in the Stock Warehouse and in the Operating Unit must be the same."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_picking.py:44
+#, python-format
+msgid "Configuration error. The Operating Unit of the picking must be the same as that of the warehouse of the Picking Type."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:65
+#, python-format
+msgid "Configuration error. The Parent Stock Location must belong to the same Operating Unit."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_move.py:39
+#, python-format
+msgid "Configuration error. The Stock moves must be related to a location (source or destination) that belongs to the requesting Operating Unit."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:35
+#: code:addons/stock_operating_unit/model/stock_location.py:40
+#, python-format
+msgid "Configuration error. The operating unit should be assigned to internal locations only."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:24
+#, python-format
+msgid "Configuration error. This location is assigned to a warehouse that belongs to a different operating unit."
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__operating_unit_dest_id
+msgid "Dest. Location Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_location
+msgid "Inventory Locations"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_warehouse_orderpoint
+msgid "Minimum Inventory Rule"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__operating_unit_id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule__operating_unit_id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__operating_unit_id
+#: model_terms:ir.ui.view,arch_db:stock_operating_unit.view_picking_internal_search
+msgid "Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__operating_unit_id
+msgid "Requesting Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__operating_unit_id
+msgid "Source Location Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_move
+msgid "Stock Move"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_rule
+msgid "Stock Rule"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_picking
+msgid "Transfer"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_warehouse
+msgid "Warehouse"
+msgstr ""
+
diff --git a/stock_operating_unit/model/__init__.py b/stock_operating_unit/model/__init__.py
index a73fea253c..6ddeb2e025 100644
--- a/stock_operating_unit/model/__init__.py
+++ b/stock_operating_unit/model/__init__.py
@@ -1,5 +1,7 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
-from . import stock
+
+from . import stock_location
+from . import stock_move
+from . import stock_picking
+from . import stock_rule
+from . import stock_warehouse
diff --git a/stock_operating_unit/model/stock.py b/stock_operating_unit/model/stock.py
deleted file mode 100644
index 10d30075fe..0000000000
--- a/stock_operating_unit/model/stock.py
+++ /dev/null
@@ -1,188 +0,0 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 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 StockWarehouse(models.Model):
- _inherit = "stock.warehouse"
-
- def _default_operating_unit(self):
- if self.company_id:
- company = self.company_id
- else:
- company = self.env['res.company']._company_default_get(
- 'stock.inventory')
- for ou in self.env.user.operating_unit_ids:
- if company == self.company_id:
- self.operating_unit_id = ou
-
- operating_unit_id = fields.Many2one(
- comodel_name='operating.unit',
- string='Operating Unit',
- default=_default_operating_unit
- )
-
- @api.multi
- @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):
- raise UserError(
- _('Configuration error\nThe Company in the Stock Warehouse'
- ' and in the Operating Unit must be the same.')
- )
-
-
-class StockLocation(models.Model):
- _inherit = 'stock.location'
-
- operating_unit_id = fields.Many2one('operating.unit',
- 'Operating Unit')
-
- @api.multi
- @api.constrains('operating_unit_id')
- def _check_warehouse_operating_unit(self):
- for rec in self:
- warehouse_obj = self.env['stock.warehouse']
- warehouses = warehouse_obj.search(
- ['|', '|', ('wh_input_stock_loc_id', '=', rec.ids[0]),
- ('lot_stock_id', 'in', rec.ids),
- ('wh_output_stock_loc_id', 'in', rec.ids)])
- for w in warehouses:
- if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error\nThis location is '
- 'assigned to a warehouse that belongs to'
- ' a different operating unit.'))
- if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error\nThis location is '
- 'assigned to a warehouse that belongs to'
- ' a different operating unit.'))
- if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error\nThis location is'
- ' assigned to a warehouse that belongs'
- ' to a different operating unit.'))
-
- @api.multi
- @api.constrains('operating_unit_id')
- def _check_required_operating_unit(self):
- for rec in self:
- if (rec.usage not in ('supplier', 'customer') and not
- rec.operating_unit_id):
- raise UserError(
- _('Configuration error. The operating unit should be '
- 'assigned to internal locations and to non other.')
- )
- if rec.usage in ('supplier', 'customer') and rec.operating_unit_id:
- raise UserError(
- _('Configuration error. The operating unit should be '
- 'assigned to internal locations and to non other.')
- )
-
- @api.multi
- @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):
- raise UserError(
- _('Configuration error\nThe Company in the Stock Location '
- 'and in the Operating Unit must be the same.'))
-
- @api.multi
- @api.constrains('operating_unit_id', 'location_id')
- def _check_parent_operating_unit(self):
- for rec in self:
- if (
- rec.location_id and
- rec.location_id.usage == 'internal' and
- rec.operating_unit_id and
- rec.operating_unit_id != rec.location_id.operating_unit_id
- ):
- raise UserError(
- _('Configuration error\nThe Parent Stock Location '
- 'must belong to the same Operating Unit.')
- )
-
-
-class StockPicking(models.Model):
- _inherit = 'stock.picking'
-
- operating_unit_id = fields.Many2one('operating.unit',
- 'Requesting Operating Unit')
-
- @api.onchange('picking_type_id', 'partner_id')
- def onchange_picking_type(self):
- res = super(StockPicking, self).onchange_picking_type()
- if self.picking_type_id:
- unit = self.picking_type_id.warehouse_id.operating_unit_id
- self.operating_unit_id = unit
- return res
-
- @api.multi
- @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):
- raise UserError(
- _('Configuration error\nThe Company in the Stock Picking '
- 'and in the Operating Unit must be the same.')
- )
-
- @api.multi
- @api.constrains('operating_unit_id', 'picking_type_id')
- def _check_picking_type_operating_unit(self):
- for rec in self:
- warehouse = rec.picking_type_id.warehouse_id
- if (rec.picking_type_id and rec.operating_unit_id and
- warehouse.operating_unit_id != rec.operating_unit_id):
- raise UserError(
- _('Configuration error\nThe Operating Unit of the picking '
- 'must be the same as that of the warehouse of the '
- 'Picking Type.')
- )
-
-
-class StockMove(models.Model):
- _inherit = 'stock.move'
-
- operating_unit_id = fields.Many2one(
- related='location_id.operating_unit_id',
- string='Source Location Operating Unit',
- readonly=True,
- )
- operating_unit_dest_id = fields.Many2one(
- related='location_dest_id.operating_unit_id',
- string='Dest. Location Operating Unit',
- readonly=True,
- )
-
- @api.multi
- @api.constrains('operating_unit_id', 'picking_id',
- 'location_id', 'operating_unit_dest_id',
- 'location_dest_id')
- def _check_stock_move_operating_unit(self):
- for stock_move in self:
- if not stock_move.operating_unit_id:
- return True
- operating_unit = stock_move.operating_unit_id
- operating_unit_dest = stock_move.operating_unit_dest_id
- if (stock_move.location_id and
- stock_move.location_id.operating_unit_id and
- stock_move.picking_id and
- operating_unit != stock_move.picking_id.operating_unit_id
- ) and (
- stock_move.location_dest_id and
- stock_move.location_dest_id.operating_unit_id and
- stock_move.picking_id and
- operating_unit_dest != stock_move.picking_id.operating_unit_id
- ):
- raise UserError(
- _('Configuration error\nThe Stock moves must '
- 'be related to a location (source or destination) '
- 'that belongs to the requesting Operating Unit.')
- )
diff --git a/stock_operating_unit/model/stock_location.py b/stock_operating_unit/model/stock_location.py
new file mode 100644
index 0000000000..61211ac91f
--- /dev/null
+++ b/stock_operating_unit/model/stock_location.py
@@ -0,0 +1,67 @@
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 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
+
+
+class StockLocation(models.Model):
+ _inherit = 'stock.location'
+
+ operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit')
+
+ @api.multi
+ @api.constrains('operating_unit_id')
+ def _check_warehouse_operating_unit(self):
+ for rec in self:
+ warehouse_obj = self.env['stock.warehouse']
+ warehouses = warehouse_obj.search(
+ ['|', '|', ('wh_input_stock_loc_id', '=', rec.ids[0]),
+ ('lot_stock_id', 'in', rec.ids),
+ ('wh_output_stock_loc_id', 'in', rec.ids)])
+ for w in warehouses:
+ if rec.operating_unit_id != w.operating_unit_id:
+ raise UserError(_('Configuration error. This location is '
+ 'assigned to a warehouse that belongs to'
+ ' a different operating unit.'))
+
+ @api.multi
+ @api.constrains('operating_unit_id')
+ def _check_required_operating_unit(self):
+ for rec in self:
+ if (rec.usage not in ('supplier', 'customer') and not
+ rec.operating_unit_id):
+ raise UserError(
+ _('Configuration error. The operating unit should be '
+ 'assigned to internal locations only.')
+ )
+ if rec.usage in ('supplier', 'customer') and rec.operating_unit_id:
+ raise UserError(
+ _('Configuration error. The operating unit should be '
+ 'assigned to internal locations only.')
+ )
+
+ @api.multi
+ @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):
+ raise UserError(
+ _('Configuration error. The Company in the Stock Location '
+ 'and in the Operating Unit must be the same.'))
+
+ @api.multi
+ @api.constrains('operating_unit_id', 'location_id')
+ def _check_parent_operating_unit(self):
+ for rec in self:
+ if (
+ rec.location_id and
+ rec.location_id.usage == 'internal' and
+ rec.operating_unit_id and
+ rec.operating_unit_id != rec.location_id.operating_unit_id
+ ):
+ raise UserError(
+ _('Configuration error. The Parent Stock Location '
+ 'must belong to the same Operating Unit.')
+ )
diff --git a/stock_operating_unit/model/stock_move.py b/stock_operating_unit/model/stock_move.py
new file mode 100644
index 0000000000..3afe5c3c11
--- /dev/null
+++ b/stock_operating_unit/model/stock_move.py
@@ -0,0 +1,42 @@
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 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
+
+
+class StockMove(models.Model):
+ _inherit = 'stock.move'
+
+ operating_unit_id = fields.Many2one(
+ related='location_id.operating_unit_id',
+ string='Source Location Operating Unit',
+ )
+ operating_unit_dest_id = fields.Many2one(
+ related='location_dest_id.operating_unit_id',
+ string='Dest. Location Operating Unit',
+ )
+
+ @api.multi
+ @api.constrains('picking_id', 'location_id', 'location_dest_id')
+ def _check_stock_move_operating_unit(self):
+ for stock_move in self:
+ if not stock_move.operating_unit_id:
+ return True
+ operating_unit = stock_move.operating_unit_id
+ operating_unit_dest = stock_move.operating_unit_dest_id
+ if (stock_move.location_id and
+ stock_move.location_id.operating_unit_id and
+ stock_move.picking_id and
+ operating_unit != stock_move.picking_id.operating_unit_id
+ ) and (
+ stock_move.location_dest_id and
+ stock_move.location_dest_id.operating_unit_id and
+ stock_move.picking_id and
+ operating_unit_dest != stock_move.picking_id.operating_unit_id
+ ):
+ raise UserError(
+ _('Configuration error. The Stock moves must '
+ 'be related to a location (source or destination) '
+ 'that belongs to the requesting Operating Unit.')
+ )
diff --git a/stock_operating_unit/model/stock_picking.py b/stock_operating_unit/model/stock_picking.py
new file mode 100644
index 0000000000..567b449e68
--- /dev/null
+++ b/stock_operating_unit/model/stock_picking.py
@@ -0,0 +1,47 @@
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 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
+
+
+class StockPicking(models.Model):
+ _inherit = 'stock.picking'
+
+ operating_unit_id = fields.Many2one(
+ 'operating.unit',
+ 'Requesting Operating Unit',
+ readonly=True,
+ states={'draft': [('readonly', False)]})
+
+ @api.onchange('picking_type_id', 'partner_id')
+ def onchange_picking_type(self):
+ res = super(StockPicking, self).onchange_picking_type()
+ if self.picking_type_id:
+ unit = self.picking_type_id.warehouse_id.operating_unit_id
+ self.operating_unit_id = unit
+ return res
+
+ @api.multi
+ @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):
+ raise UserError(
+ _('Configuration error. The Company in the Stock Picking '
+ 'and in the Operating Unit must be the same.')
+ )
+
+ @api.multi
+ @api.constrains('operating_unit_id', 'picking_type_id')
+ def _check_picking_type_operating_unit(self):
+ for rec in self:
+ warehouse = rec.picking_type_id.warehouse_id
+ if (rec.picking_type_id and rec.operating_unit_id and
+ warehouse.operating_unit_id != rec.operating_unit_id):
+ raise UserError(
+ _('Configuration error. The Operating Unit of the picking '
+ 'must be the same as that of the warehouse of the '
+ 'Picking Type.')
+ )
diff --git a/stock_operating_unit/model/stock_rule.py b/stock_operating_unit/model/stock_rule.py
new file mode 100644
index 0000000000..764a8c98e7
--- /dev/null
+++ b/stock_operating_unit/model/stock_rule.py
@@ -0,0 +1,14 @@
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 Serpent Consulting Services Pvt. Ltd.
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
+
+from odoo import fields, models
+
+
+class StockRule(models.Model):
+ _inherit = 'stock.rule'
+
+ operating_unit_id = fields.Many2one(
+ 'operating.unit',
+ related='warehouse_id.operating_unit_id',
+ domain="[('user_ids', '=', uid)]")
diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
new file mode 100644
index 0000000000..f1832f739f
--- /dev/null
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -0,0 +1,52 @@
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 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
+
+
+class StockWarehouse(models.Model):
+ _inherit = "stock.warehouse"
+
+ def _default_operating_unit(self):
+ if self.company_id:
+ company = self.company_id
+ else:
+ company = self.env['res.company']._company_default_get(
+ 'stock.inventory')
+ for ou in self.env.user.operating_unit_ids:
+ if company == self.company_id:
+ self.operating_unit_id = ou
+
+ operating_unit_id = fields.Many2one(
+ comodel_name='operating.unit',
+ string='Operating Unit',
+ default=_default_operating_unit
+ )
+
+ @api.multi
+ @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):
+ raise UserError(
+ _('Configuration error. The Company in the Stock Warehouse'
+ ' and in the Operating Unit must be the same.')
+ )
+
+
+class StockWarehouseOrderPoint(models.Model):
+ _inherit = 'stock.warehouse.orderpoint'
+
+ @api.multi
+ @api.constrains('operating_unit_id', 'warehouse_id', 'location_id')
+ def _check_location(self):
+ for rec in self:
+ if (rec.warehouse_id and rec.location_id and
+ rec.warehouse_id.operating_unit_id !=
+ rec.location_id.operating_unit_id):
+ raise UserError(
+ _('Configuration Error. The Operating Unit of the '
+ 'Warehouse and the Location must be the same. ')
+ )
diff --git a/stock_operating_unit/readme/CONFIGURE.rst b/stock_operating_unit/readme/CONFIGURE.rst
new file mode 100644
index 0000000000..583881a77f
--- /dev/null
+++ b/stock_operating_unit/readme/CONFIGURE.rst
@@ -0,0 +1,4 @@
+To configure this module, you need to:
+
+* Assign Operating Unit to Warehouses.
+* Assign Operating Unit to Stock Locations.
diff --git a/stock_operating_unit/readme/CONTRIBUTORS.rst b/stock_operating_unit/readme/CONTRIBUTORS.rst
new file mode 100644
index 0000000000..4244f4e535
--- /dev/null
+++ b/stock_operating_unit/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
+* Jordi Ballester Alomar
+* Aaron Henriquez
+* Sudhir Arya
diff --git a/stock_operating_unit/readme/DESCRIPTION.rst b/stock_operating_unit/readme/DESCRIPTION.rst
new file mode 100644
index 0000000000..6534ea9ce8
--- /dev/null
+++ b/stock_operating_unit/readme/DESCRIPTION.rst
@@ -0,0 +1,6 @@
+This module introduces the following features:
+
+- Adds the operating unit to the Warehouse.
+- Adds the operating unit to the Stock Location.
+- Adds the requesting operating unit to stock pickings.
+- Implements user's security access rules.
diff --git a/stock_operating_unit/readme/ROADMAP.rst b/stock_operating_unit/readme/ROADMAP.rst
new file mode 100644
index 0000000000..241598c034
--- /dev/null
+++ b/stock_operating_unit/readme/ROADMAP.rst
@@ -0,0 +1,3 @@
+The Manager can see the stock rules of other Operating Units but he can not
+edit them. If he tries to access to one of these stock rules, he will receive
+a configuration error.
diff --git a/stock_operating_unit/readme/USAGE.rst b/stock_operating_unit/readme/USAGE.rst
new file mode 100644
index 0000000000..281f39c0b3
--- /dev/null
+++ b/stock_operating_unit/readme/USAGE.rst
@@ -0,0 +1,2 @@
+This module defines the operating unit entity and the user's security rules.
+Other modules extend the standard Odoo apps with the OU.
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index 5f5e829d32..c76a1dbdf1 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -1,11 +1,14 @@
-
-
+
- ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ ['|',
+ ('operating_unit_id', '=', False),
+ ('operating_unit_id', 'in', user.operating_unit_ids.ids)]
+
Warehouses from allowed operating units
@@ -16,7 +19,10 @@
- ['|',('warehouse_id.operating_unit_id','=',False),('warehouse_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ ['|',
+ ('warehouse_id.operating_unit_id','=', False),
+ ('warehouse_id.operating_unit_id','in',user.operating_unit_ids.ids)]
+
Stock Picking Type from allowed operating units
@@ -27,8 +33,10 @@
- ['|', ('operating_unit_id','in',[g.id for g
- in user.operating_unit_ids]), ('operating_unit_id','=', False)]
+ ['|',
+ ('operating_unit_id', 'in',user.operating_unit_ids.ids),
+ ('operating_unit_id','=',False)]
+
Stock locations from allowed operating units
@@ -39,8 +47,13 @@
- ['|',('location_id.operating_unit_id','=',False),('location_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids]),
- '|',('location_dest_id.operating_unit_id','=',False),('location_dest_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ ['|',
+ ('location_id.operating_unit_id','=',False),
+ ('location_id.operating_unit_id','in',user.operating_unit_ids.ids),
+ '|',
+ ('location_dest_id.operating_unit_id','=',False),
+ ('location_dest_id.operating_unit_id','in',user.operating_unit_ids.ids)]
+
Stock moves from allowed operating units
@@ -51,7 +64,10 @@
- ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]
+ ['|',
+ ('operating_unit_id','=',False),
+ ('operating_unit_id','in',user.operating_unit_ids.ids)]
+
Stock pickings from allowed operating units
@@ -60,4 +76,17 @@
+
+
+ ['|',
+ ('picking_type_id.warehouse_id.operating_unit_id','=',False),
+ ('picking_type_id.warehouse_id.operating_unit_id','in',user.operating_unit_ids.ids)]
+
+ Stock pickings from allowed picking types
+
+
+
+
+
+
diff --git a/stock_operating_unit/static/description/index.html b/stock_operating_unit/static/description/index.html
new file mode 100644
index 0000000000..af48c054dc
--- /dev/null
+++ b/stock_operating_unit/static/description/index.html
@@ -0,0 +1,450 @@
+
+
+
+
+
+
+Stock with Operating Units
+
+
+
+
+
Stock with Operating Units
+
+
+

+
This module introduces the following features:
+
+- Adds the operating unit to the Warehouse.
+- Adds the operating unit to the Stock Location.
+- Adds the requesting operating unit to stock pickings.
+- Implements user’s security access rules.
+
+
Table of contents
+
+
+
+
To configure this module, you need to:
+
+- Assign Operating Unit to Warehouses.
+- Assign Operating Unit to Stock Locations.
+
+
+
+
+
This module defines the operating unit entity and the user’s security rules.
+Other modules extend the standard Odoo apps with the OU.
+
+
+
+
The Manager can see the stock rules of other Operating Units but he can not
+edit them. If he tries to access to one of these stock rules, he will receive
+a configuration error.
+
+
+
+
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.
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+- Eficent
+- Serpent Consulting Services Pvt. Ltd.
+
+
+
+
+
+
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.
+
This module is part of the OCA/operating-unit project on GitHub.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+
+
+
+
+
diff --git a/stock_operating_unit/tests/__init__.py b/stock_operating_unit/tests/__init__.py
index 2aacf0c00a..0e6f8d0396 100644
--- a/stock_operating_unit/tests/__init__.py
+++ b/stock_operating_unit/tests/__init__.py
@@ -1,8 +1,5 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# - Jordi Ballester Alomar
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
+
from . import test_stock_operating_unit
from . import test_stock_picking
from . import test_stock_security
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index 61c0549d06..071368f48d 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -1,8 +1,7 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
-from openerp.addons.stock.tests import common
+from odoo.addons.stock.tests import common
class TestStockOperatingUnit(common.TestStockCommon):
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
index 29ff52b82c..e601ea9e4d 100644
--- a/stock_operating_unit/tests/test_stock_picking.py
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -1,6 +1,5 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_operating_unit as test_stock_ou
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index 61001a4704..885e29a26e 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -1,6 +1,5 @@
-# -*- coding: utf-8 -*-
-# © 2016-2017 Eficent Business and IT Consulting Services S.L.
-# © 2016-2017 Serpent Consulting Services Pvt. Ltd.
+# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_operating_unit as test_stock_ou
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index ecfbbd9094..0daf31e89e 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -1,17 +1,20 @@
-
+
stock.warehouse
stock.warehouse
-
-
+
-
+
@@ -20,9 +23,12 @@
stock.warehouse
-
-
-
+
+
+
@@ -31,10 +37,12 @@
stock.location
-
-
+
-
+
@@ -43,9 +51,11 @@
stock.location
-
-
-
+
+
+
@@ -54,9 +64,11 @@
stock.location
-
-
-
+
+
+
@@ -65,9 +77,11 @@
stock.picking
-
-
-
+
+
+
@@ -76,10 +90,15 @@
stock.picking
-
-
+
-
+
+
+ [('warehouse_id.operating_unit_id.user_ids', 'in', uid)]
+
@@ -89,12 +108,15 @@
-
+
-
-
+
-
+
@@ -103,12 +125,16 @@
stock.move
-
-
-
-
-
-
+
+
+
+
+
+
@@ -117,12 +143,34 @@
stock.move
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ stock.move.form
+ stock.move
+
+
+
+
+
+
+
+
@@ -132,12 +180,16 @@
move_history_ids
-
-
-
-
-
-
+
+
+
+
+
+
@@ -146,12 +198,16 @@
stock.move
-
-
-
-
-
-
+
+
+
+
+
+
From ed0d5ebd2715a40c59f8eb00d2570e659d2c3b2f Mon Sep 17 00:00:00 2001
From: mreficent
Date: Wed, 27 Nov 2019 19:09:33 +0100
Subject: [PATCH 22/49] [FIX] Alignments
---
stock_operating_unit/model/stock_warehouse.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
index f1832f739f..d3daa77f3a 100644
--- a/stock_operating_unit/model/stock_warehouse.py
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -46,7 +46,7 @@ def _check_location(self):
if (rec.warehouse_id and rec.location_id and
rec.warehouse_id.operating_unit_id !=
rec.location_id.operating_unit_id):
- raise UserError(
- _('Configuration Error. The Operating Unit of the '
- 'Warehouse and the Location must be the same. ')
- )
+ raise UserError(
+ _('Configuration Error. The Operating Unit of the '
+ 'Warehouse and the Location must be the same. ')
+ )
From 9176c33fc6938fb61ddd1a6ca515e66f4b3a9f8f Mon Sep 17 00:00:00 2001
From: BT-nstuder
Date: Mon, 6 Jan 2020 14:58:20 +0100
Subject: [PATCH 23/49] [IMP] stock_operating_unit: black, isort, prettier
---
stock_operating_unit/__manifest__.py | 14 +-
stock_operating_unit/data/stock_data.xml | 9 +-
stock_operating_unit/demo/stock_demo.xml | 35 ++-
stock_operating_unit/hooks.py | 17 +-
stock_operating_unit/model/stock_location.py | 80 ++++---
stock_operating_unit/model/stock_move.py | 38 ++--
stock_operating_unit/model/stock_picking.py | 43 ++--
stock_operating_unit/model/stock_rule.py | 9 +-
stock_operating_unit/model/stock_warehouse.py | 43 ++--
.../security/stock_security.xml | 84 ++++----
.../tests/test_stock_operating_unit.py | 139 ++++++------
.../tests/test_stock_picking.py | 24 ++-
.../tests/test_stock_security.py | 131 +++++++-----
stock_operating_unit/view/stock.xml | 202 ++++++++++--------
14 files changed, 487 insertions(+), 381 deletions(-)
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index 242f1a5fa1..fa22b00a70 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -8,19 +8,13 @@
"version": "12.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent, "
- "Serpent Consulting Services Pvt. Ltd., "
- "Odoo Community Association (OCA)",
+ "Serpent Consulting Services Pvt. Ltd., "
+ "Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "https://github.com/OCA/operating-unit",
"depends": ["stock", "account_operating_unit"],
- "data": [
- "security/stock_security.xml",
- "data/stock_data.xml",
- "view/stock.xml",
- ],
- "demo": [
- "demo/stock_demo.xml",
- ],
+ "data": ["security/stock_security.xml", "data/stock_data.xml", "view/stock.xml"],
+ "demo": ["demo/stock_demo.xml"],
"installable": True,
"post_init_hook": "update_operating_unit_location",
}
diff --git a/stock_operating_unit/data/stock_data.xml b/stock_operating_unit/data/stock_data.xml
index 9b40fabd0f..07fd4ce261 100644
--- a/stock_operating_unit/data/stock_data.xml
+++ b/stock_operating_unit/data/stock_data.xml
@@ -1,15 +1,12 @@
-
+
-
-
+
-
-
+
-
diff --git a/stock_operating_unit/demo/stock_demo.xml b/stock_operating_unit/demo/stock_demo.xml
index ca255a9a16..b8fd651c38 100644
--- a/stock_operating_unit/demo/stock_demo.xml
+++ b/stock_operating_unit/demo/stock_demo.xml
@@ -1,58 +1,49 @@
-
+
-
-
+
-
-
+
-
Your company child
-
Chicago
CH
-
-
+
+
-
-
+
-
-
+
-
B2B Warehouse
B2B
-
-
-
+
+
+
-
B2C Warehouse
B2C
-
-
-
+
+
+
-
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
index 7b66a21a45..56d54961ea 100644
--- a/stock_operating_unit/hooks.py
+++ b/stock_operating_unit/hooks.py
@@ -7,16 +7,17 @@
def update_operating_unit_location(cr, registry):
env = Environment(cr, SUPERUSER_ID, {})
- warehouses = env['stock.warehouse'].search([])
+ warehouses = env["stock.warehouse"].search([])
for warehouse in warehouses:
operating_unit = warehouse.operating_unit_id
parent_location = warehouse.view_location_id
- locations = env['stock.location'].search(
- [('id', 'child_of', [parent_location.id]),
- ('usage', '=', 'internal')])
+ locations = env["stock.location"].search(
+ [("id", "child_of", [parent_location.id]), ("usage", "=", "internal")]
+ )
if operating_unit:
- query = '''update stock_location set operating_unit_id = %s where
- location_id in %s or id in %s'''
- cr.execute(query, (operating_unit.id, tuple(locations.ids),
- tuple(locations.ids)))
+ query = """update stock_location set operating_unit_id = %s where
+ location_id in %s or id in %s"""
+ cr.execute(
+ query, (operating_unit.id, tuple(locations.ids), tuple(locations.ids))
+ )
return True
diff --git a/stock_operating_unit/model/stock_location.py b/stock_operating_unit/model/stock_location.py
index 61211ac91f..6f59a9bed1 100644
--- a/stock_operating_unit/model/stock_location.py
+++ b/stock_operating_unit/model/stock_location.py
@@ -6,62 +6,82 @@
class StockLocation(models.Model):
- _inherit = 'stock.location'
+ _inherit = "stock.location"
- operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit')
+ operating_unit_id = fields.Many2one("operating.unit", "Operating Unit")
@api.multi
- @api.constrains('operating_unit_id')
+ @api.constrains("operating_unit_id")
def _check_warehouse_operating_unit(self):
for rec in self:
- warehouse_obj = self.env['stock.warehouse']
+ warehouse_obj = self.env["stock.warehouse"]
warehouses = warehouse_obj.search(
- ['|', '|', ('wh_input_stock_loc_id', '=', rec.ids[0]),
- ('lot_stock_id', 'in', rec.ids),
- ('wh_output_stock_loc_id', 'in', rec.ids)])
+ [
+ "|",
+ "|",
+ ("wh_input_stock_loc_id", "=", rec.ids[0]),
+ ("lot_stock_id", "in", rec.ids),
+ ("wh_output_stock_loc_id", "in", rec.ids),
+ ]
+ )
for w in warehouses:
if rec.operating_unit_id != w.operating_unit_id:
- raise UserError(_('Configuration error. This location is '
- 'assigned to a warehouse that belongs to'
- ' a different operating unit.'))
+ raise UserError(
+ _(
+ "Configuration error. This location is "
+ "assigned to a warehouse that belongs to"
+ " a different operating unit."
+ )
+ )
@api.multi
- @api.constrains('operating_unit_id')
+ @api.constrains("operating_unit_id")
def _check_required_operating_unit(self):
for rec in self:
- if (rec.usage not in ('supplier', 'customer') and not
- rec.operating_unit_id):
+ if rec.usage not in ("supplier", "customer") and not rec.operating_unit_id:
raise UserError(
- _('Configuration error. The operating unit should be '
- 'assigned to internal locations only.')
+ _(
+ "Configuration error. The operating unit should be "
+ "assigned to internal locations only."
+ )
)
- if rec.usage in ('supplier', 'customer') and rec.operating_unit_id:
+ if rec.usage in ("supplier", "customer") and rec.operating_unit_id:
raise UserError(
- _('Configuration error. The operating unit should be '
- 'assigned to internal locations only.')
+ _(
+ "Configuration error. The operating unit should be "
+ "assigned to internal locations only."
+ )
)
@api.multi
- @api.constrains('operating_unit_id', 'company_id')
+ @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. The Company in the Stock Location '
- 'and in the Operating Unit must be the same.'))
+ _(
+ "Configuration error. The Company in the Stock Location "
+ "and in the Operating Unit must be the same."
+ )
+ )
@api.multi
- @api.constrains('operating_unit_id', 'location_id')
+ @api.constrains("operating_unit_id", "location_id")
def _check_parent_operating_unit(self):
for rec in self:
if (
- rec.location_id and
- rec.location_id.usage == 'internal' and
- rec.operating_unit_id and
- rec.operating_unit_id != rec.location_id.operating_unit_id
+ rec.location_id
+ and rec.location_id.usage == "internal"
+ and rec.operating_unit_id
+ and rec.operating_unit_id != rec.location_id.operating_unit_id
):
raise UserError(
- _('Configuration error. The Parent Stock Location '
- 'must belong to the same Operating Unit.')
+ _(
+ "Configuration error. The Parent Stock Location "
+ "must belong to the same Operating Unit."
+ )
)
diff --git a/stock_operating_unit/model/stock_move.py b/stock_operating_unit/model/stock_move.py
index 3afe5c3c11..87b815c06a 100644
--- a/stock_operating_unit/model/stock_move.py
+++ b/stock_operating_unit/model/stock_move.py
@@ -6,37 +6,39 @@
class StockMove(models.Model):
- _inherit = 'stock.move'
+ _inherit = "stock.move"
operating_unit_id = fields.Many2one(
- related='location_id.operating_unit_id',
- string='Source Location Operating Unit',
+ related="location_id.operating_unit_id", string="Source Location Operating Unit"
)
operating_unit_dest_id = fields.Many2one(
- related='location_dest_id.operating_unit_id',
- string='Dest. Location Operating Unit',
+ related="location_dest_id.operating_unit_id",
+ string="Dest. Location Operating Unit",
)
@api.multi
- @api.constrains('picking_id', 'location_id', 'location_dest_id')
+ @api.constrains("picking_id", "location_id", "location_dest_id")
def _check_stock_move_operating_unit(self):
for stock_move in self:
if not stock_move.operating_unit_id:
return True
operating_unit = stock_move.operating_unit_id
operating_unit_dest = stock_move.operating_unit_dest_id
- if (stock_move.location_id and
- stock_move.location_id.operating_unit_id and
- stock_move.picking_id and
- operating_unit != stock_move.picking_id.operating_unit_id
- ) and (
- stock_move.location_dest_id and
- stock_move.location_dest_id.operating_unit_id and
- stock_move.picking_id and
- operating_unit_dest != stock_move.picking_id.operating_unit_id
+ if (
+ stock_move.location_id
+ and stock_move.location_id.operating_unit_id
+ and stock_move.picking_id
+ and operating_unit != stock_move.picking_id.operating_unit_id
+ ) and (
+ stock_move.location_dest_id
+ and stock_move.location_dest_id.operating_unit_id
+ and stock_move.picking_id
+ and operating_unit_dest != stock_move.picking_id.operating_unit_id
):
raise UserError(
- _('Configuration error. The Stock moves must '
- 'be related to a location (source or destination) '
- 'that belongs to the requesting Operating Unit.')
+ _(
+ "Configuration error. The Stock moves must "
+ "be related to a location (source or destination) "
+ "that belongs to the requesting Operating Unit."
+ )
)
diff --git a/stock_operating_unit/model/stock_picking.py b/stock_operating_unit/model/stock_picking.py
index 567b449e68..86ecdd1700 100644
--- a/stock_operating_unit/model/stock_picking.py
+++ b/stock_operating_unit/model/stock_picking.py
@@ -6,15 +6,16 @@
class StockPicking(models.Model):
- _inherit = 'stock.picking'
+ _inherit = "stock.picking"
operating_unit_id = fields.Many2one(
- 'operating.unit',
- 'Requesting Operating Unit',
+ "operating.unit",
+ "Requesting Operating Unit",
readonly=True,
- states={'draft': [('readonly', False)]})
+ states={"draft": [("readonly", False)]},
+ )
- @api.onchange('picking_type_id', 'partner_id')
+ @api.onchange("picking_type_id", "partner_id")
def onchange_picking_type(self):
res = super(StockPicking, self).onchange_picking_type()
if self.picking_type_id:
@@ -23,25 +24,35 @@ def onchange_picking_type(self):
return res
@api.multi
- @api.constrains('operating_unit_id', 'company_id')
+ @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. The Company in the Stock Picking '
- 'and in the Operating Unit must be the same.')
+ _(
+ "Configuration error. The Company in the Stock Picking "
+ "and in the Operating Unit must be the same."
+ )
)
@api.multi
- @api.constrains('operating_unit_id', 'picking_type_id')
+ @api.constrains("operating_unit_id", "picking_type_id")
def _check_picking_type_operating_unit(self):
for rec in self:
warehouse = rec.picking_type_id.warehouse_id
- if (rec.picking_type_id and rec.operating_unit_id and
- warehouse.operating_unit_id != rec.operating_unit_id):
+ if (
+ rec.picking_type_id
+ and rec.operating_unit_id
+ and warehouse.operating_unit_id != rec.operating_unit_id
+ ):
raise UserError(
- _('Configuration error. The Operating Unit of the picking '
- 'must be the same as that of the warehouse of the '
- 'Picking Type.')
+ _(
+ "Configuration error. The Operating Unit of the picking "
+ "must be the same as that of the warehouse of the "
+ "Picking Type."
+ )
)
diff --git a/stock_operating_unit/model/stock_rule.py b/stock_operating_unit/model/stock_rule.py
index 764a8c98e7..d2515f0687 100644
--- a/stock_operating_unit/model/stock_rule.py
+++ b/stock_operating_unit/model/stock_rule.py
@@ -6,9 +6,10 @@
class StockRule(models.Model):
- _inherit = 'stock.rule'
+ _inherit = "stock.rule"
operating_unit_id = fields.Many2one(
- 'operating.unit',
- related='warehouse_id.operating_unit_id',
- domain="[('user_ids', '=', uid)]")
+ "operating.unit",
+ related="warehouse_id.operating_unit_id",
+ domain="[('user_ids', '=', uid)]",
+ )
diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
index d3daa77f3a..5ae235b02b 100644
--- a/stock_operating_unit/model/stock_warehouse.py
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -12,41 +12,50 @@ def _default_operating_unit(self):
if self.company_id:
company = self.company_id
else:
- company = self.env['res.company']._company_default_get(
- 'stock.inventory')
+ company = self.env["res.company"]._company_default_get("stock.inventory")
for ou in self.env.user.operating_unit_ids:
if company == self.company_id:
self.operating_unit_id = ou
operating_unit_id = fields.Many2one(
- comodel_name='operating.unit',
- string='Operating Unit',
- default=_default_operating_unit
+ comodel_name="operating.unit",
+ string="Operating Unit",
+ default=_default_operating_unit,
)
@api.multi
- @api.constrains('operating_unit_id', 'company_id')
+ @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. The Company in the Stock Warehouse'
- ' and in the Operating Unit must be the same.')
+ _(
+ "Configuration error. The Company in the Stock Warehouse"
+ " and in the Operating Unit must be the same."
+ )
)
class StockWarehouseOrderPoint(models.Model):
- _inherit = 'stock.warehouse.orderpoint'
+ _inherit = "stock.warehouse.orderpoint"
@api.multi
- @api.constrains('operating_unit_id', 'warehouse_id', 'location_id')
+ @api.constrains("operating_unit_id", "warehouse_id", "location_id")
def _check_location(self):
for rec in self:
- if (rec.warehouse_id and rec.location_id and
- rec.warehouse_id.operating_unit_id !=
- rec.location_id.operating_unit_id):
+ if (
+ rec.warehouse_id
+ and rec.location_id
+ and rec.warehouse_id.operating_unit_id
+ != rec.location_id.operating_unit_id
+ ):
raise UserError(
- _('Configuration Error. The Operating Unit of the '
- 'Warehouse and the Location must be the same. ')
+ _(
+ "Configuration Error. The Operating Unit of the "
+ "Warehouse and the Location must be the same. "
+ )
)
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index c76a1dbdf1..c00756a139 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -1,52 +1,49 @@
-
+
-
+
['|',
('operating_unit_id', '=', False),
('operating_unit_id', 'in', user.operating_unit_ids.ids)]
Warehouses from allowed operating units
-
-
-
-
-
+
+
+
+
+
-
-
+
['|',
('warehouse_id.operating_unit_id','=', False),
('warehouse_id.operating_unit_id','in',user.operating_unit_ids.ids)]
Stock Picking Type from allowed operating units
-
-
-
-
-
+
+
+
+
+
-
-
+
['|',
('operating_unit_id', 'in',user.operating_unit_ids.ids),
('operating_unit_id','=',False)]
Stock locations from allowed operating units
-
-
-
-
-
+
+
+
+
+
-
-
+
['|',
('location_id.operating_unit_id','=',False),
('location_id.operating_unit_id','in',user.operating_unit_ids.ids),
@@ -55,38 +52,39 @@
('location_dest_id.operating_unit_id','in',user.operating_unit_ids.ids)]
Stock moves from allowed operating units
-
-
-
-
-
+
+
+
+
+
-
-
+
['|',
('operating_unit_id','=',False),
('operating_unit_id','in',user.operating_unit_ids.ids)]
Stock pickings from allowed operating units
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
['|',
('picking_type_id.warehouse_id.operating_unit_id','=',False),
('picking_type_id.warehouse_id.operating_unit_id','in',user.operating_unit_ids.ids)]
Stock pickings from allowed picking types
-
-
-
-
-
+
+
+
+
+
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index 071368f48d..47ce0f203a 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -5,90 +5,99 @@
class TestStockOperatingUnit(common.TestStockCommon):
-
def setUp(self):
super(TestStockOperatingUnit, self).setUp()
- self.ResUsers = self.env['res.users']
- self.WarehouseObj = self.env['stock.warehouse']
- self.LocationObj = self.env['stock.location']
+ self.ResUsers = self.env["res.users"]
+ self.WarehouseObj = self.env["stock.warehouse"]
+ self.LocationObj = self.env["stock.location"]
# company
- self.company1 = self.env.ref('base.main_company')
+ self.company1 = self.env.ref("base.main_company")
# groups
- self.group_stock_manager = self.env.ref('stock.group_stock_manager')
+ self.group_stock_manager = self.env.ref("stock.group_stock_manager")
# Main Operating Unit
- self.ou1 = self.env.ref('operating_unit.main_operating_unit')
+ self.ou1 = self.env.ref("operating_unit.main_operating_unit")
# B2C Operating Unit
- self.b2c = self.env.ref('operating_unit.b2c_operating_unit')
+ self.b2c = self.env.ref("operating_unit.b2c_operating_unit")
# 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')
+ 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")
# Locations
- b2c_wh = self.env.ref('stock_operating_unit.stock_warehouse_b2c')
- b2c_wh.lot_stock_id.write({'operating_unit_id': self.b2c.id})
+ b2c_wh = self.env.ref("stock_operating_unit.stock_warehouse_b2c")
+ b2c_wh.lot_stock_id.write({"operating_unit_id": self.b2c.id})
self.location_b2c_id = b2c_wh.lot_stock_id.id
self.b2c_type_in_id = b2c_wh.in_type_id.id
self.b2c_type_int_id = b2c_wh.int_type_id.id
# Create users
- self.user1_id = self._create_user('stock_user_1',
- [self.group_stock_manager],
- self.company1,
- [self.ou1, self.b2c])
- self.user2_id = self._create_user('stock_user_2',
- [self.group_stock_manager],
- self.company1,
- [self.b2c])
+ self.user1_id = self._create_user(
+ "stock_user_1",
+ [self.group_stock_manager],
+ self.company1,
+ [self.ou1, self.b2c],
+ )
+ self.user2_id = self._create_user(
+ "stock_user_2", [self.group_stock_manager], self.company1, [self.b2c]
+ )
# Create Incoming Shipments
- self.picking_in1 = self._create_picking(self.user1_id,
- self.b2c.id,
- self.b2c_type_in_id,
- self.supplier_location,
- self.stock_location)
- self.picking_in2 = self._create_picking(self.user2_id,
- self.b2c.id,
- self.b2c_type_in_id,
- self.supplier_location,
- self.location_b2c_id)
+ self.picking_in1 = self._create_picking(
+ self.user1_id,
+ self.b2c.id,
+ self.b2c_type_in_id,
+ self.supplier_location,
+ self.stock_location,
+ )
+ self.picking_in2 = self._create_picking(
+ self.user2_id,
+ self.b2c.id,
+ self.b2c_type_in_id,
+ self.supplier_location,
+ self.location_b2c_id,
+ )
# Create Internal Shipment
- self.picking_int = self._create_picking(self.user1_id,
- self.b2c.id,
- self.b2c_type_int_id,
- self.stock_location,
- self.location_b2c_id)
+ self.picking_int = self._create_picking(
+ self.user1_id,
+ self.b2c.id,
+ self.b2c_type_int_id,
+ self.stock_location,
+ self.location_b2c_id,
+ )
def _create_user(self, login, groups, company, operating_units):
""" Create a user."""
group_ids = [group.id for group in groups]
- user =\
- self.ResUsers.with_context({'no_reset_password': True}).\
- create({
- 'name': 'Stock User',
- 'login': login,
- 'password': 'demo',
- 'email': 'chicago@yourcompany.com',
- 'company_id': company.id,
- 'company_ids': [(4, company.id)],
- 'operating_unit_ids': [(4, ou.id) for ou in operating_units],
- 'groups_id': [(6, 0, group_ids)]
- })
+ user = self.ResUsers.with_context({"no_reset_password": True}).create(
+ {
+ "name": "Stock User",
+ "login": login,
+ "password": "demo",
+ "email": "chicago@yourcompany.com",
+ "company_id": company.id,
+ "company_ids": [(4, company.id)],
+ "operating_unit_ids": [(4, ou.id) for ou in operating_units],
+ "groups_id": [(6, 0, group_ids)],
+ }
+ )
return user.id
- def _create_picking(self, user_id, ou_id, picking_type, src_loc_id,
- dest_loc_id):
+ def _create_picking(self, user_id, ou_id, picking_type, src_loc_id, dest_loc_id):
"""Create a Picking."""
- picking = self.PickingObj.sudo(user_id).create({
- 'picking_type_id': picking_type,
- 'location_id': src_loc_id,
- 'location_dest_id': dest_loc_id,
- 'operating_unit_id': ou_id,
- })
- self.MoveObj.sudo(user_id).create({
- 'name': 'a move',
- 'product_id': self.productA.id,
- 'product_uom_qty': 3.0,
- 'product_uom': self.productA.uom_id.id,
- 'picking_id': picking.id,
- 'location_id': src_loc_id,
- 'location_dest_id': dest_loc_id,
- })
+ picking = self.PickingObj.sudo(user_id).create(
+ {
+ "picking_type_id": picking_type,
+ "location_id": src_loc_id,
+ "location_dest_id": dest_loc_id,
+ "operating_unit_id": ou_id,
+ }
+ )
+ self.MoveObj.sudo(user_id).create(
+ {
+ "name": "a move",
+ "product_id": self.productA.id,
+ "product_uom_qty": 3.0,
+ "product_uom": self.productA.uom_id.id,
+ "picking_id": picking.id,
+ "location_id": src_loc_id,
+ "location_dest_id": dest_loc_id,
+ }
+ )
return picking
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
index e601ea9e4d..fc68daaa42 100644
--- a/stock_operating_unit/tests/test_stock_picking.py
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -5,15 +5,23 @@
class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
-
def test_stock_picking_ou(self):
"""Test Pickings of Stock Operating Unit"""
- picking_ids = self.PickingObj.sudo(self.user1_id).\
- search([('id', '=', self.picking_in1.id)]).ids
- self.assertNotEqual(picking_ids, [], '')
- picking_ids = self.PickingObj.sudo(self.user2_id).\
- search([('id', '=', self.picking_in2.id)]).ids
+ picking_ids = (
+ self.PickingObj.sudo(self.user1_id)
+ .search([("id", "=", self.picking_in1.id)])
+ .ids
+ )
+ self.assertNotEqual(picking_ids, [], "")
+ picking_ids = (
+ self.PickingObj.sudo(self.user2_id)
+ .search([("id", "=", self.picking_in2.id)])
+ .ids
+ )
self.assertNotEqual(picking_ids, [])
- picking_ids = self.PickingObj.sudo(self.user1_id).\
- search([('id', '=', self.picking_int.id)]).ids
+ picking_ids = (
+ self.PickingObj.sudo(self.user1_id)
+ .search([("id", "=", self.picking_int.id)])
+ .ids
+ )
self.assertNotEqual(picking_ids, [])
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index 885e29a26e..59416bc7cc 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -5,62 +5,97 @@
class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
-
def test_stock_ou_security(self):
"""Test Security of Stock Operating Unit"""
# User 1 can list the warehouses assigned to
# Main and B2C OU
- wh_ids =\
- self.WarehouseObj.sudo(self.user1_id).\
- search([('operating_unit_id', 'in',
- [self.ou1.id, self.b2c.id])]).ids
- self.assertNotEqual(wh_ids, [], 'User does not have access to'
- 'Warehouses which belong to Main and B2C'
- 'Operating Unit.')
+ wh_ids = (
+ self.WarehouseObj.sudo(self.user1_id)
+ .search([("operating_unit_id", "in", [self.ou1.id, self.b2c.id])])
+ .ids
+ )
+ self.assertNotEqual(
+ wh_ids,
+ [],
+ "User does not have access to"
+ "Warehouses which belong to Main and B2C"
+ "Operating Unit.",
+ )
# User 1 can list the locations assigned to Main and b2c OU
- location_ids =\
- self.LocationObj.sudo(self.user1_id).\
- search([('operating_unit_id', 'in',
- [self.ou1.id, self.b2c.id])]).ids
- self.assertNotEqual(location_ids, [], 'User does not have access to'
- 'Locations which belong to Main and B2C'
- 'Operating Unit.')
+ location_ids = (
+ self.LocationObj.sudo(self.user1_id)
+ .search([("operating_unit_id", "in", [self.ou1.id, self.b2c.id])])
+ .ids
+ )
+ self.assertNotEqual(
+ location_ids,
+ [],
+ "User does not have access to"
+ "Locations which belong to Main and B2C"
+ "Operating Unit.",
+ )
# User 2 cannot list the warehouses assigned to Main OU
- wh_ids =\
- self.WarehouseObj.sudo(self.user2_id).\
- search([('operating_unit_id', '=', self.ou1.id)]).ids
- self.assertEqual(wh_ids, [], 'User 2 should not be able to list'
- 'the warehouses assigned to Main Operating Unit.')
+ wh_ids = (
+ self.WarehouseObj.sudo(self.user2_id)
+ .search([("operating_unit_id", "=", self.ou1.id)])
+ .ids
+ )
+ self.assertEqual(
+ wh_ids,
+ [],
+ "User 2 should not be able to list"
+ "the warehouses assigned to Main Operating Unit.",
+ )
# User 2 cannot list the locations assigned to Main OU
- location_ids =\
- self.LocationObj.sudo(self.user2_id).\
- search([('operating_unit_id', 'in',
- [self.ou1.id])]).ids
- self.assertEqual(location_ids, [], 'User 2 should not be able to list'
- 'the locations assigned to Main OU.')
- pickings = [self.picking_in1.id, self.picking_in2.id,
- self.picking_int.id]
+ location_ids = (
+ self.LocationObj.sudo(self.user2_id)
+ .search([("operating_unit_id", "in", [self.ou1.id])])
+ .ids
+ )
+ self.assertEqual(
+ location_ids,
+ [],
+ "User 2 should not be able to list" "the locations assigned to Main OU.",
+ )
+ pickings = [self.picking_in1.id, self.picking_in2.id, self.picking_int.id]
# User 1 can list the pickings 1, 2, 3
- picking_ids =\
- self.PickingObj.sudo(self.user1_id).search([('id', 'in',
- pickings)]).ids
- self.assertNotEqual(picking_ids, [], 'User 1 cannot list the'
- 'pickings assigned to pickings 1, 2, 3.')
+ picking_ids = (
+ self.PickingObj.sudo(self.user1_id).search([("id", "in", pickings)]).ids
+ )
+ self.assertNotEqual(
+ picking_ids,
+ [],
+ "User 1 cannot list the" "pickings assigned to pickings 1, 2, 3.",
+ )
# User 1 can list the stock moves assigned to pickings 1, 2, 3
- move_ids =\
- self.MoveObj.sudo(self.user1_id).search([('picking_id', 'in',
- pickings)]).ids
- self.assertNotEqual(move_ids, [], 'User 1 cannot list the'
- 'stock moves assigned to pickings 1, 2, 3.')
+ move_ids = (
+ self.MoveObj.sudo(self.user1_id)
+ .search([("picking_id", "in", pickings)])
+ .ids
+ )
+ self.assertNotEqual(
+ move_ids,
+ [],
+ "User 1 cannot list the" "stock moves assigned to pickings 1, 2, 3.",
+ )
# User 2 cannot list the the stock moves assigned to picking 1
- move_ids =\
- self.MoveObj.sudo(self.user2_id).\
- search([('picking_id', '=', self.picking_in1.id)]).ids
- self.assertEqual(move_ids, [], 'User 2 should not be able to list the '
- 'stock moves assigned to picking 1.')
+ move_ids = (
+ self.MoveObj.sudo(self.user2_id)
+ .search([("picking_id", "=", self.picking_in1.id)])
+ .ids
+ )
+ self.assertEqual(
+ move_ids,
+ [],
+ "User 2 should not be able to list the "
+ "stock moves assigned to picking 1.",
+ )
# User 2 can list the picking 1
- picking_ids =\
- self.PickingObj.sudo(self.user2_id).\
- search([('id', '=', self.picking_in1.id)]).ids
- self.assertEqual(len(picking_ids), 1, 'User 2 should be able to list'
- 'the picking 1.')
+ picking_ids = (
+ self.PickingObj.sudo(self.user2_id)
+ .search([("id", "=", self.picking_in1.id)])
+ .ids
+ )
+ self.assertEqual(
+ len(picking_ids), 1, "User 2 should be able to list" "the picking 1."
+ )
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index 0daf31e89e..b7526c99b4 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -1,214 +1,244 @@
-
+
-
stock.warehouse
stock.warehouse
-
+
-
+ groups="operating_unit.group_multi_operating_unit"
+ />
-
stock.warehouse.tree
stock.warehouse
-
+
-
-
stock.location.form
stock.location
-
+
-
+ groups="operating_unit.group_multi_operating_unit"
+ />
-
stock.location.tree
stock.location
-
+
-
+
-
stock.location.search
stock.location
-
+
-
+
-
stock.picking.tree
stock.picking
-
+
-
+
-
stock.picking.form
stock.picking
-
+
-
+ groups="operating_unit.group_multi_operating_unit"
+ />
- [('warehouse_id.operating_unit_id.user_ids', 'in', uid)]
+ [('warehouse_id.operating_unit_id.user_ids', 'in', uid)]
-
stock.picking.internal.search
stock.picking
-
+
-
+
-
+
-
stock.move.tree
stock.move
-
+
-
+
-
+
-
stock.move.tree
stock.move
-
+
-
+
-
+
-
stock.move.form
stock.move
-
+
-
+
-
+
-
Stock Moves
stock.move
move_history_ids
-
+
-
+
-
+
-
stock.move.form
stock.move
-
+
-
+
-
+
-
From 6d00e80a67609b65d5d289af059a7244c9c6dd73 Mon Sep 17 00:00:00 2001
From: BT-nstuder
Date: Thu, 2 Apr 2020 14:52:58 +0200
Subject: [PATCH 24/49] [MIG] stock_operating_unit: Migration to 13.0
---
stock_operating_unit/README.rst | 12 ++++----
stock_operating_unit/__manifest__.py | 4 +--
.../i18n/stock_operating_unit.pot | 2 +-
stock_operating_unit/model/stock_location.py | 4 ---
stock_operating_unit/model/stock_move.py | 1 -
stock_operating_unit/model/stock_picking.py | 2 --
stock_operating_unit/model/stock_warehouse.py | 4 +--
stock_operating_unit/readme/CONTRIBUTORS.rst | 1 +
.../static/description/index.html | 6 ++--
.../tests/test_stock_operating_unit.py | 4 +--
.../tests/test_stock_picking.py | 6 ++--
.../tests/test_stock_security.py | 18 ++++++------
stock_operating_unit/view/stock.xml | 28 ++++---------------
13 files changed, 34 insertions(+), 58 deletions(-)
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index ef0c9a5939..440bcaf5fe 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -14,16 +14,16 @@ Stock with Operating Units
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
- :target: https://github.com/OCA/operating-unit/tree/12.0/stock_operating_unit
+ :target: https://github.com/OCA/operating-unit/tree/13.0/stock_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-stock_operating_unit
+ :target: https://translation.odoo-community.org/projects/operating-unit-13-0/operating-unit-13-0-stock_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/213/12.0
+ :target: https://runbot.odoo-community.org/runbot/213/13.0
:alt: Try me on Runbot
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
This module introduces the following features:
@@ -64,7 +64,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -97,6 +97,6 @@ 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.
-This module is part of the `OCA/operating-unit `_ project on GitHub.
+This module is part of the `OCA/operating-unit `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index fa22b00a70..48dd3838fb 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -5,14 +5,14 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "12.0.1.0.0",
+ "version": "13.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent, "
"Serpent Consulting Services Pvt. Ltd., "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "https://github.com/OCA/operating-unit",
- "depends": ["stock", "account_operating_unit"],
+ "depends": ["stock", "operating_unit"],
"data": ["security/stock_security.xml", "data/stock_data.xml", "view/stock.xml"],
"demo": ["demo/stock_demo.xml"],
"installable": True,
diff --git a/stock_operating_unit/i18n/stock_operating_unit.pot b/stock_operating_unit/i18n/stock_operating_unit.pot
index 0705b99dff..0a40d24db9 100644
--- a/stock_operating_unit/i18n/stock_operating_unit.pot
+++ b/stock_operating_unit/i18n/stock_operating_unit.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
diff --git a/stock_operating_unit/model/stock_location.py b/stock_operating_unit/model/stock_location.py
index 6f59a9bed1..032cc22cb0 100644
--- a/stock_operating_unit/model/stock_location.py
+++ b/stock_operating_unit/model/stock_location.py
@@ -10,7 +10,6 @@ class StockLocation(models.Model):
operating_unit_id = fields.Many2one("operating.unit", "Operating Unit")
- @api.multi
@api.constrains("operating_unit_id")
def _check_warehouse_operating_unit(self):
for rec in self:
@@ -34,7 +33,6 @@ def _check_warehouse_operating_unit(self):
)
)
- @api.multi
@api.constrains("operating_unit_id")
def _check_required_operating_unit(self):
for rec in self:
@@ -53,7 +51,6 @@ def _check_required_operating_unit(self):
)
)
- @api.multi
@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for rec in self:
@@ -69,7 +66,6 @@ def _check_company_operating_unit(self):
)
)
- @api.multi
@api.constrains("operating_unit_id", "location_id")
def _check_parent_operating_unit(self):
for rec in self:
diff --git a/stock_operating_unit/model/stock_move.py b/stock_operating_unit/model/stock_move.py
index 87b815c06a..2bb1da0cae 100644
--- a/stock_operating_unit/model/stock_move.py
+++ b/stock_operating_unit/model/stock_move.py
@@ -16,7 +16,6 @@ class StockMove(models.Model):
string="Dest. Location Operating Unit",
)
- @api.multi
@api.constrains("picking_id", "location_id", "location_dest_id")
def _check_stock_move_operating_unit(self):
for stock_move in self:
diff --git a/stock_operating_unit/model/stock_picking.py b/stock_operating_unit/model/stock_picking.py
index 86ecdd1700..a21b8ccd15 100644
--- a/stock_operating_unit/model/stock_picking.py
+++ b/stock_operating_unit/model/stock_picking.py
@@ -23,7 +23,6 @@ def onchange_picking_type(self):
self.operating_unit_id = unit
return res
- @api.multi
@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for rec in self:
@@ -39,7 +38,6 @@ def _check_company_operating_unit(self):
)
)
- @api.multi
@api.constrains("operating_unit_id", "picking_type_id")
def _check_picking_type_operating_unit(self):
for rec in self:
diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
index 5ae235b02b..cf8b50468a 100644
--- a/stock_operating_unit/model/stock_warehouse.py
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -12,7 +12,7 @@ def _default_operating_unit(self):
if self.company_id:
company = self.company_id
else:
- company = self.env["res.company"]._company_default_get("stock.inventory")
+ company = self.env.company
for ou in self.env.user.operating_unit_ids:
if company == self.company_id:
self.operating_unit_id = ou
@@ -23,7 +23,6 @@ def _default_operating_unit(self):
default=_default_operating_unit,
)
- @api.multi
@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for rec in self:
@@ -43,7 +42,6 @@ def _check_company_operating_unit(self):
class StockWarehouseOrderPoint(models.Model):
_inherit = "stock.warehouse.orderpoint"
- @api.multi
@api.constrains("operating_unit_id", "warehouse_id", "location_id")
def _check_location(self):
for rec in self:
diff --git a/stock_operating_unit/readme/CONTRIBUTORS.rst b/stock_operating_unit/readme/CONTRIBUTORS.rst
index 4244f4e535..d5625161d4 100644
--- a/stock_operating_unit/readme/CONTRIBUTORS.rst
+++ b/stock_operating_unit/readme/CONTRIBUTORS.rst
@@ -1,3 +1,4 @@
* Jordi Ballester Alomar
* Aaron Henriquez
* Sudhir Arya
+* Nicola Studer
diff --git a/stock_operating_unit/static/description/index.html b/stock_operating_unit/static/description/index.html
index af48c054dc..6bdc35ee43 100644
--- a/stock_operating_unit/static/description/index.html
+++ b/stock_operating_unit/static/description/index.html
@@ -367,7 +367,7 @@ Stock with Operating Units
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module introduces the following features:
- Adds the operating unit to the Warehouse.
@@ -414,7 +414,7 @@
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -441,7 +441,7 @@
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.
-
This module is part of the OCA/operating-unit project on GitHub.
+
This module is part of the OCA/operating-unit project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index 47ce0f203a..e28a2618be 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -81,7 +81,7 @@ def _create_user(self, login, groups, company, operating_units):
def _create_picking(self, user_id, ou_id, picking_type, src_loc_id, dest_loc_id):
"""Create a Picking."""
- picking = self.PickingObj.sudo(user_id).create(
+ picking = self.PickingObj.with_user(user_id).create(
{
"picking_type_id": picking_type,
"location_id": src_loc_id,
@@ -89,7 +89,7 @@ def _create_picking(self, user_id, ou_id, picking_type, src_loc_id, dest_loc_id)
"operating_unit_id": ou_id,
}
)
- self.MoveObj.sudo(user_id).create(
+ self.MoveObj.with_user(user_id).create(
{
"name": "a move",
"product_id": self.productA.id,
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
index fc68daaa42..70d2f4893e 100644
--- a/stock_operating_unit/tests/test_stock_picking.py
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -8,19 +8,19 @@ class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
def test_stock_picking_ou(self):
"""Test Pickings of Stock Operating Unit"""
picking_ids = (
- self.PickingObj.sudo(self.user1_id)
+ self.PickingObj.with_user(self.user1_id)
.search([("id", "=", self.picking_in1.id)])
.ids
)
self.assertNotEqual(picking_ids, [], "")
picking_ids = (
- self.PickingObj.sudo(self.user2_id)
+ self.PickingObj.with_user(self.user2_id)
.search([("id", "=", self.picking_in2.id)])
.ids
)
self.assertNotEqual(picking_ids, [])
picking_ids = (
- self.PickingObj.sudo(self.user1_id)
+ self.PickingObj.with_user(self.user1_id)
.search([("id", "=", self.picking_int.id)])
.ids
)
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index 59416bc7cc..cf6f3cac20 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -10,7 +10,7 @@ def test_stock_ou_security(self):
# User 1 can list the warehouses assigned to
# Main and B2C OU
wh_ids = (
- self.WarehouseObj.sudo(self.user1_id)
+ self.WarehouseObj.with_user(self.user1_id)
.search([("operating_unit_id", "in", [self.ou1.id, self.b2c.id])])
.ids
)
@@ -23,7 +23,7 @@ def test_stock_ou_security(self):
)
# User 1 can list the locations assigned to Main and b2c OU
location_ids = (
- self.LocationObj.sudo(self.user1_id)
+ self.LocationObj.with_user(self.user1_id)
.search([("operating_unit_id", "in", [self.ou1.id, self.b2c.id])])
.ids
)
@@ -36,7 +36,7 @@ def test_stock_ou_security(self):
)
# User 2 cannot list the warehouses assigned to Main OU
wh_ids = (
- self.WarehouseObj.sudo(self.user2_id)
+ self.WarehouseObj.with_user(self.user2_id)
.search([("operating_unit_id", "=", self.ou1.id)])
.ids
)
@@ -48,7 +48,7 @@ def test_stock_ou_security(self):
)
# User 2 cannot list the locations assigned to Main OU
location_ids = (
- self.LocationObj.sudo(self.user2_id)
+ self.LocationObj.with_user(self.user2_id)
.search([("operating_unit_id", "in", [self.ou1.id])])
.ids
)
@@ -60,7 +60,9 @@ def test_stock_ou_security(self):
pickings = [self.picking_in1.id, self.picking_in2.id, self.picking_int.id]
# User 1 can list the pickings 1, 2, 3
picking_ids = (
- self.PickingObj.sudo(self.user1_id).search([("id", "in", pickings)]).ids
+ self.PickingObj.with_user(self.user1_id)
+ .search([("id", "in", pickings)])
+ .ids
)
self.assertNotEqual(
picking_ids,
@@ -69,7 +71,7 @@ def test_stock_ou_security(self):
)
# User 1 can list the stock moves assigned to pickings 1, 2, 3
move_ids = (
- self.MoveObj.sudo(self.user1_id)
+ self.MoveObj.with_user(self.user1_id)
.search([("picking_id", "in", pickings)])
.ids
)
@@ -80,7 +82,7 @@ def test_stock_ou_security(self):
)
# User 2 cannot list the the stock moves assigned to picking 1
move_ids = (
- self.MoveObj.sudo(self.user2_id)
+ self.MoveObj.with_user(self.user2_id)
.search([("picking_id", "=", self.picking_in1.id)])
.ids
)
@@ -92,7 +94,7 @@ def test_stock_ou_security(self):
)
# User 2 can list the picking 1
picking_ids = (
- self.PickingObj.sudo(self.user2_id)
+ self.PickingObj.with_user(self.user2_id)
.search([("id", "=", self.picking_in1.id)])
.ids
)
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index b7526c99b4..c48e64a7d4 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -96,7 +96,10 @@
stock.picking
-
+
-
+
-
- stock.move.form
- stock.move
-
-
-
-
-
-
-
-
-
-
Stock Moves
stock.move
From 6b0c9a329eff947f5d07725f06dc588d21340725 Mon Sep 17 00:00:00 2001
From: BT-nstuder
Date: Mon, 6 Apr 2020 08:03:59 +0200
Subject: [PATCH 25/49] [IMP] stock_operating_unit: Update record rule
---
stock_operating_unit/security/stock_security.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index c00756a139..a6d5ba3d88 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -76,7 +76,8 @@
model="ir.rule"
>
- ['|',
+ ['|','|',
+ ('picking_type_id.warehouse_id','=', False),
('picking_type_id.warehouse_id.operating_unit_id','=',False),
('picking_type_id.warehouse_id.operating_unit_id','in',user.operating_unit_ids.ids)]
From 7fd08cc8a79c905ebaf40aa649b249d39e607997 Mon Sep 17 00:00:00 2001
From: BT-nstuder
Date: Mon, 6 Apr 2020 08:13:54 +0200
Subject: [PATCH 26/49] [FIX] stock_operating_unit: Constraint on stock move
---
stock_operating_unit/model/stock_move.py | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/stock_operating_unit/model/stock_move.py b/stock_operating_unit/model/stock_move.py
index 2bb1da0cae..ddc007cc8d 100644
--- a/stock_operating_unit/model/stock_move.py
+++ b/stock_operating_unit/model/stock_move.py
@@ -19,21 +19,10 @@ class StockMove(models.Model):
@api.constrains("picking_id", "location_id", "location_dest_id")
def _check_stock_move_operating_unit(self):
for stock_move in self:
- if not stock_move.operating_unit_id:
- return True
- operating_unit = stock_move.operating_unit_id
- operating_unit_dest = stock_move.operating_unit_dest_id
- if (
- stock_move.location_id
- and stock_move.location_id.operating_unit_id
- and stock_move.picking_id
- and operating_unit != stock_move.picking_id.operating_unit_id
- ) and (
- stock_move.location_dest_id
- and stock_move.location_dest_id.operating_unit_id
- and stock_move.picking_id
- and operating_unit_dest != stock_move.picking_id.operating_unit_id
- ):
+ ou_pick = stock_move.picking_id.operating_unit_id or False
+ ou_src = stock_move.operating_unit_id or False
+ ou_dest = stock_move.operating_unit_dest_id or False
+ if ou_src and ou_pick and (ou_src != ou_pick) and (ou_dest != ou_pick):
raise UserError(
_(
"Configuration error. The Stock moves must "
From 142f446f80a68a6b732cf188f82a2de7fccf03b6 Mon Sep 17 00:00:00 2001
From: ahenriquez
Date: Mon, 20 Apr 2020 13:27:33 +0200
Subject: [PATCH 27/49] [IMP]add operating unit rule in stock.move.line
---
stock_operating_unit/README.rst | 3 +-
.../i18n/stock_operating_unit.pot | 61 ++++++++++++-------
.../security/stock_security.xml | 16 +++++
.../static/description/index.html | 1 +
4 files changed, 58 insertions(+), 23 deletions(-)
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index 440bcaf5fe..08d577e26d 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -23,7 +23,7 @@ Stock with Operating Units
:target: https://runbot.odoo-community.org/runbot/213/13.0
:alt: Try me on Runbot
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
This module introduces the following features:
@@ -83,6 +83,7 @@ Contributors
* Jordi Ballester Alomar
* Aaron Henriquez
* Sudhir Arya
+* Nicola Studer
Maintainers
~~~~~~~~~~~
diff --git a/stock_operating_unit/i18n/stock_operating_unit.pot b/stock_operating_unit/i18n/stock_operating_unit.pot
index 0a40d24db9..2cc48c8e81 100644
--- a/stock_operating_unit/i18n/stock_operating_unit.pot
+++ b/stock_operating_unit/i18n/stock_operating_unit.pot
@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * stock_operating_unit
+# * stock_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: <>\n"
+"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -14,58 +14,76 @@ msgstr ""
"Plural-Forms: \n"
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_warehouse.py:50
+#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
#, python-format
-msgid "Configuration Error. The Operating Unit of the Warehouse and the Location must be the same. "
+msgid ""
+"Configuration Error. The Operating Unit of the Warehouse and the Location "
+"must be the same. "
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_location.py:51
+#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
-msgid "Configuration error. The Company in the Stock Location and in the Operating Unit must be the same."
+msgid ""
+"Configuration error. The Company in the Stock Location and in the Operating "
+"Unit must be the same."
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_picking.py:32
+#: code:addons/stock_operating_unit/model/stock_picking.py:0
#, python-format
-msgid "Configuration error. The Company in the Stock Picking and in the Operating Unit must be the same."
+msgid ""
+"Configuration error. The Company in the Stock Picking and in the Operating "
+"Unit must be the same."
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_warehouse.py:34
+#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
#, python-format
-msgid "Configuration error. The Company in the Stock Warehouse and in the Operating Unit must be the same."
+msgid ""
+"Configuration error. The Company in the Stock Warehouse and in the Operating"
+" Unit must be the same."
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_picking.py:44
+#: code:addons/stock_operating_unit/model/stock_picking.py:0
#, python-format
-msgid "Configuration error. The Operating Unit of the picking must be the same as that of the warehouse of the Picking Type."
+msgid ""
+"Configuration error. The Operating Unit of the picking must be the same as "
+"that of the warehouse of the Picking Type."
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_location.py:65
+#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
-msgid "Configuration error. The Parent Stock Location must belong to the same Operating Unit."
+msgid ""
+"Configuration error. The Parent Stock Location must belong to the same "
+"Operating Unit."
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_move.py:39
+#: code:addons/stock_operating_unit/model/stock_move.py:0
#, python-format
-msgid "Configuration error. The Stock moves must be related to a location (source or destination) that belongs to the requesting Operating Unit."
+msgid ""
+"Configuration error. The Stock moves must be related to a location (source "
+"or destination) that belongs to the requesting Operating Unit."
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_location.py:35
-#: code:addons/stock_operating_unit/model/stock_location.py:40
+#: code:addons/stock_operating_unit/model/stock_location.py:0
+#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
-msgid "Configuration error. The operating unit should be assigned to internal locations only."
+msgid ""
+"Configuration error. The operating unit should be assigned to internal "
+"locations only."
msgstr ""
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_location.py:24
+#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
-msgid "Configuration error. This location is assigned to a warehouse that belongs to a different operating unit."
+msgid ""
+"Configuration error. This location is assigned to a warehouse that belongs "
+"to a different operating unit."
msgstr ""
#. module: stock_operating_unit
@@ -120,4 +138,3 @@ msgstr ""
#: model:ir.model,name:stock_operating_unit.model_stock_warehouse
msgid "Warehouse"
msgstr ""
-
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index a6d5ba3d88..1cddae5e64 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -58,6 +58,22 @@
+
+
+ ['|',
+ ('location_id.operating_unit_id','=',False),
+ ('location_id.operating_unit_id','in',user.operating_unit_ids.ids),
+ '|',
+ ('location_dest_id.operating_unit_id','=',False),
+ ('location_dest_id.operating_unit_id','in',user.operating_unit_ids.ids)]
+
+ Product moves from allowed operating units
+
+
+
+
+
+
['|',
diff --git a/stock_operating_unit/static/description/index.html b/stock_operating_unit/static/description/index.html
index 6bdc35ee43..46e913fb4f 100644
--- a/stock_operating_unit/static/description/index.html
+++ b/stock_operating_unit/static/description/index.html
@@ -432,6 +432,7 @@
Jordi Ballester Alomar <jordi.ballester@eficent.com>
Aaron Henriquez <aheficent@eficent.com>
Sudhir Arya <sudhir.arya@serpentcs.com>
+Nicola Studer <nicola.studer@braintec-group.com>
From 23e3cbb400accd04edf8967d6c4bd19d1e82fff2 Mon Sep 17 00:00:00 2001
From: mreficent
Date: Mon, 5 Oct 2020 10:42:21 +0200
Subject: [PATCH 28/49] [UPD] Eficent -> ForgeFlow
---
stock_operating_unit/README.rst | 6 +++---
stock_operating_unit/__manifest__.py | 4 ++--
stock_operating_unit/data/stock_data.xml | 2 +-
stock_operating_unit/demo/stock_demo.xml | 2 +-
stock_operating_unit/hooks.py | 2 +-
stock_operating_unit/model/stock_location.py | 2 +-
stock_operating_unit/model/stock_move.py | 2 +-
stock_operating_unit/model/stock_picking.py | 2 +-
stock_operating_unit/model/stock_rule.py | 2 +-
stock_operating_unit/model/stock_warehouse.py | 2 +-
stock_operating_unit/readme/CONTRIBUTORS.rst | 4 ++--
stock_operating_unit/security/stock_security.xml | 2 +-
stock_operating_unit/static/description/index.html | 6 +++---
stock_operating_unit/tests/test_stock_operating_unit.py | 2 +-
stock_operating_unit/tests/test_stock_picking.py | 2 +-
stock_operating_unit/tests/test_stock_security.py | 2 +-
stock_operating_unit/view/stock.xml | 2 +-
17 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index 08d577e26d..c5d999f56a 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -74,14 +74,14 @@ Credits
Authors
~~~~~~~
-* Eficent
+* ForgeFlow
* Serpent Consulting Services Pvt. Ltd.
Contributors
~~~~~~~~~~~~
-* Jordi Ballester Alomar
-* Aaron Henriquez
+* Jordi Ballester Alomar
+* Aaron Henriquez
* Sudhir Arya
* Nicola Studer
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index 48dd3838fb..dd19c7773d 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
@@ -7,7 +7,7 @@
"summary": "Adds the concept of operating unit (OU) in stock management",
"version": "13.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
- "author": "Eficent, "
+ "author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
diff --git a/stock_operating_unit/data/stock_data.xml b/stock_operating_unit/data/stock_data.xml
index 07fd4ce261..41a7091d71 100644
--- a/stock_operating_unit/data/stock_data.xml
+++ b/stock_operating_unit/data/stock_data.xml
@@ -1,5 +1,5 @@
-
diff --git a/stock_operating_unit/demo/stock_demo.xml b/stock_operating_unit/demo/stock_demo.xml
index b8fd651c38..e70d475c81 100644
--- a/stock_operating_unit/demo/stock_demo.xml
+++ b/stock_operating_unit/demo/stock_demo.xml
@@ -1,5 +1,5 @@
-
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
index 56d54961ea..eac7697edd 100644
--- a/stock_operating_unit/hooks.py
+++ b/stock_operating_unit/hooks.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import SUPERUSER_ID
diff --git a/stock_operating_unit/model/stock_location.py b/stock_operating_unit/model/stock_location.py
index 032cc22cb0..3635370cdf 100644
--- a/stock_operating_unit/model/stock_location.py
+++ b/stock_operating_unit/model/stock_location.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
diff --git a/stock_operating_unit/model/stock_move.py b/stock_operating_unit/model/stock_move.py
index ddc007cc8d..4406016f6f 100644
--- a/stock_operating_unit/model/stock_move.py
+++ b/stock_operating_unit/model/stock_move.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
diff --git a/stock_operating_unit/model/stock_picking.py b/stock_operating_unit/model/stock_picking.py
index a21b8ccd15..cdb681c686 100644
--- a/stock_operating_unit/model/stock_picking.py
+++ b/stock_operating_unit/model/stock_picking.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
diff --git a/stock_operating_unit/model/stock_rule.py b/stock_operating_unit/model/stock_rule.py
index d2515f0687..2ba9764be6 100644
--- a/stock_operating_unit/model/stock_rule.py
+++ b/stock_operating_unit/model/stock_rule.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
index cf8b50468a..322334b384 100644
--- a/stock_operating_unit/model/stock_warehouse.py
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
diff --git a/stock_operating_unit/readme/CONTRIBUTORS.rst b/stock_operating_unit/readme/CONTRIBUTORS.rst
index d5625161d4..8b06c257aa 100644
--- a/stock_operating_unit/readme/CONTRIBUTORS.rst
+++ b/stock_operating_unit/readme/CONTRIBUTORS.rst
@@ -1,4 +1,4 @@
-* Jordi Ballester Alomar
-* Aaron Henriquez
+* Jordi Ballester Alomar
+* Aaron Henriquez
* Sudhir Arya
* Nicola Studer
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index 1cddae5e64..5d7f01fe0b 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -1,5 +1,5 @@
-
diff --git a/stock_operating_unit/static/description/index.html b/stock_operating_unit/static/description/index.html
index 46e913fb4f..e307a6e957 100644
--- a/stock_operating_unit/static/description/index.html
+++ b/stock_operating_unit/static/description/index.html
@@ -422,15 +422,15 @@
-- Eficent
+- ForgeFlow
- Serpent Consulting Services Pvt. Ltd.
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index e28a2618be..ac8ce52a32 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo.addons.stock.tests import common
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
index 70d2f4893e..7416a6f5b4 100644
--- a/stock_operating_unit/tests/test_stock_picking.py
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_operating_unit as test_stock_ou
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index cf6f3cac20..d20f3318c4 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# © 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_operating_unit as test_stock_ou
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index c48e64a7d4..0086676961 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -1,5 +1,5 @@
-
From 898e3fcf6287f06589907ac34ba3528dfe66b751 Mon Sep 17 00:00:00 2001
From: Kitti U
Date: Fri, 4 Dec 2020 13:55:44 +0700
Subject: [PATCH 29/49] [14.0][MIG] stock_operating_unit
---
stock_operating_unit/__manifest__.py | 2 +-
stock_operating_unit/readme/CONTRIBUTORS.rst | 1 +
stock_operating_unit/view/stock.xml | 10 ++++------
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index dd19c7773d..2ab3e171cd 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "13.0.1.0.0",
+ "version": "14.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/readme/CONTRIBUTORS.rst b/stock_operating_unit/readme/CONTRIBUTORS.rst
index 8b06c257aa..882e94eeac 100644
--- a/stock_operating_unit/readme/CONTRIBUTORS.rst
+++ b/stock_operating_unit/readme/CONTRIBUTORS.rst
@@ -2,3 +2,4 @@
* Aaron Henriquez
* Sudhir Arya
* Nicola Studer
+* Kitti U.
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index 0086676961..d9ae07fc9b 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -131,7 +131,6 @@
@@ -159,10 +158,10 @@
-
+
stock.move.tree
stock.move
-
+
-
+
Stock Moves
stock.move
- move_history_ids
-
+
Date: Wed, 15 Jan 2020 10:17:52 -0800
Subject: [PATCH 30/49] [IMP] Multi Ware Access
---
stock_operating_unit/README.rst | 11 ++++---
.../i18n/stock_operating_unit.pot | 32 ++++++++++++++++++-
stock_operating_unit/model/stock_location.py | 2 +-
stock_operating_unit/model/stock_picking.py | 3 +-
stock_operating_unit/model/stock_warehouse.py | 6 ++--
.../static/description/index.html | 7 ++--
6 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index c5d999f56a..1a066c8a2f 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -14,13 +14,13 @@ Stock with Operating Units
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
- :target: https://github.com/OCA/operating-unit/tree/13.0/stock_operating_unit
+ :target: https://github.com/OCA/operating-unit/tree/14.0/stock_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/operating-unit-13-0/operating-unit-13-0-stock_operating_unit
+ :target: https://translation.odoo-community.org/projects/operating-unit-14-0/operating-unit-14-0-stock_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/213/13.0
+ :target: https://runbot.odoo-community.org/runbot/213/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -64,7 +64,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -84,6 +84,7 @@ Contributors
* Aaron Henriquez
* Sudhir Arya
* Nicola Studer
+* Kitti U.
Maintainers
~~~~~~~~~~~
@@ -98,6 +99,6 @@ 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.
-This module is part of the `OCA/operating-unit `_ project on GitHub.
+This module is part of the `OCA/operating-unit `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_operating_unit/i18n/stock_operating_unit.pot b/stock_operating_unit/i18n/stock_operating_unit.pot
index 2cc48c8e81..ee8fb27a4c 100644
--- a/stock_operating_unit/i18n/stock_operating_unit.pot
+++ b/stock_operating_unit/i18n/stock_operating_unit.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 13.0\n"
+"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -91,11 +91,41 @@ msgstr ""
msgid "Dest. Location Operating Unit"
msgstr ""
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__display_name
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__display_name
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__display_name
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule__display_name
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__display_name
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse_orderpoint__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule__id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse_orderpoint__id
+msgid "ID"
+msgstr ""
+
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_location
msgid "Inventory Locations"
msgstr ""
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location____last_update
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move____last_update
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking____last_update
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule____last_update
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse____last_update
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse_orderpoint____last_update
+msgid "Last Modified on"
+msgstr ""
+
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
diff --git a/stock_operating_unit/model/stock_location.py b/stock_operating_unit/model/stock_location.py
index 3635370cdf..03d37aba2a 100644
--- a/stock_operating_unit/model/stock_location.py
+++ b/stock_operating_unit/model/stock_location.py
@@ -24,7 +24,7 @@ def _check_warehouse_operating_unit(self):
]
)
for w in warehouses:
- if rec.operating_unit_id != w.operating_unit_id:
+ if w.operating_unit_id and rec.operating_unit_id != w.operating_unit_id:
raise UserError(
_(
"Configuration error. This location is "
diff --git a/stock_operating_unit/model/stock_picking.py b/stock_operating_unit/model/stock_picking.py
index cdb681c686..4269ea4c6f 100644
--- a/stock_operating_unit/model/stock_picking.py
+++ b/stock_operating_unit/model/stock_picking.py
@@ -43,7 +43,8 @@ def _check_picking_type_operating_unit(self):
for rec in self:
warehouse = rec.picking_type_id.warehouse_id
if (
- rec.picking_type_id
+ warehouse.operating_unit_id
+ and rec.picking_type_id
and rec.operating_unit_id
and warehouse.operating_unit_id != rec.operating_unit_id
):
diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
index 322334b384..06e5b78194 100644
--- a/stock_operating_unit/model/stock_warehouse.py
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -27,7 +27,8 @@ def _default_operating_unit(self):
def _check_company_operating_unit(self):
for rec in self:
if (
- rec.company_id
+ rec.operating_unit_id
+ and rec.company_id
and rec.operating_unit_id
and rec.company_id != rec.operating_unit_id.company_id
):
@@ -46,7 +47,8 @@ class StockWarehouseOrderPoint(models.Model):
def _check_location(self):
for rec in self:
if (
- rec.warehouse_id
+ rec.warehouse_id.operating_unit_id
+ and rec.warehouse_id
and rec.location_id
and rec.warehouse_id.operating_unit_id
!= rec.location_id.operating_unit_id
diff --git a/stock_operating_unit/static/description/index.html b/stock_operating_unit/static/description/index.html
index e307a6e957..e1ea87a724 100644
--- a/stock_operating_unit/static/description/index.html
+++ b/stock_operating_unit/static/description/index.html
@@ -367,7 +367,7 @@ Stock with Operating Units
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module introduces the following features:
- Adds the operating unit to the Warehouse.
@@ -414,7 +414,7 @@
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -442,7 +443,7 @@
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.
-
This module is part of the OCA/operating-unit project on GitHub.
+
This module is part of the OCA/operating-unit project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
From f5c943bee3ae9c466d11a0f756d7b065ef83d861 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jesu=CC=81s=20Alan=20Ramos=20Rodri=CC=81guez?=
Date: Tue, 17 Aug 2021 09:48:09 -0500
Subject: [PATCH 31/49] [FIX] stock_operating_unit: fix warning in orderpoint
constraint operating_unit_id is not field of model stock.warehouse.orderpoint
---
stock_operating_unit/__manifest__.py | 2 +-
stock_operating_unit/model/stock_warehouse.py | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index 2ab3e171cd..2b8100f603 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "14.0.1.0.0",
+ "version": "14.0.1.0.1",
"category": "Generic Modules/Sales & Purchases",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
index 06e5b78194..3404c13eb7 100644
--- a/stock_operating_unit/model/stock_warehouse.py
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -43,7 +43,12 @@ def _check_company_operating_unit(self):
class StockWarehouseOrderPoint(models.Model):
_inherit = "stock.warehouse.orderpoint"
- @api.constrains("operating_unit_id", "warehouse_id", "location_id")
+ @api.constrains(
+ "warehouse_id",
+ "location_id",
+ "location_id.operating_unit_id",
+ "warehouse_id.operating_unit_id",
+ )
def _check_location(self):
for rec in self:
if (
From b3a85e6034ccb97818252e7e402f62fbf8692d8f Mon Sep 17 00:00:00 2001
From: Graeme Gellatly
Date: Mon, 10 Jan 2022 12:02:15 +1300
Subject: [PATCH 32/49] [14.0] stock_operating_unit: Add Record Rule to Quants.
Without this rule, a user will not be able to view the inventory report if they do not belong to all operating units of all the companies they belong.
---
stock_operating_unit/__manifest__.py | 2 +-
stock_operating_unit/security/stock_security.xml | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index 2b8100f603..0e28b5386f 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "14.0.1.0.1",
+ "version": "14.0.1.0.2",
"category": "Generic Modules/Sales & Purchases",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index 5d7f01fe0b..cb5dd0aec3 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -104,4 +104,17 @@
+
+
+ ['|',
+ ('location_id.operating_unit_id', '=', False),
+ ('location_id.operating_unit_id', 'in', user.operating_unit_ids.ids)]
+
+ Quants from allowed operating units
+
+
+
+
+
+
From ccfe1674ac880a4de47da57947b18a9c26b30f41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jesu=CC=81s=20Alan=20Ramos=20Rodri=CC=81guez?=
Date: Tue, 29 Mar 2022 07:56:34 -0600
Subject: [PATCH 33/49] [IMP] stock_operating_unit: black, isort, prettier
---
stock_operating_unit/tests/test_stock_operating_unit.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index ac8ce52a32..f860a3ccff 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -63,7 +63,7 @@ def setUp(self):
)
def _create_user(self, login, groups, company, operating_units):
- """ Create a user."""
+ """Create a user."""
group_ids = [group.id for group in groups]
user = self.ResUsers.with_context({"no_reset_password": True}).create(
{
From 678beb001c761c5c2111ee22fb8a5d30a4fa9b90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jesu=CC=81s=20Alan=20Ramos=20Rodri=CC=81guez?=
Date: Tue, 29 Mar 2022 07:57:41 -0600
Subject: [PATCH 34/49] [MIG] stock_operating_unit: Migration to 15.0
---
stock_operating_unit/README.rst | 11 +++---
stock_operating_unit/__manifest__.py | 6 +--
stock_operating_unit/hooks.py | 4 +-
.../i18n/stock_operating_unit.pot | 38 ++++---------------
.../migrations/15.0.1.0.0/pre-migration.py | 16 ++++++++
stock_operating_unit/model/__init__.py | 1 +
stock_operating_unit/model/stock_location.py | 4 +-
stock_operating_unit/model/stock_move.py | 4 +-
stock_operating_unit/model/stock_picking.py | 11 +++---
stock_operating_unit/model/stock_quant.py | 12 ++++++
stock_operating_unit/model/stock_rule.py | 4 +-
stock_operating_unit/model/stock_warehouse.py | 6 +--
stock_operating_unit/readme/CONTRIBUTORS.rst | 1 +
.../security/stock_security.xml | 6 +--
.../static/description/index.html | 7 ++--
.../tests/test_stock_operating_unit.py | 6 +--
.../tests/test_stock_picking.py | 8 +++-
.../tests/test_stock_security.py | 8 +++-
18 files changed, 83 insertions(+), 70 deletions(-)
create mode 100644 stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
create mode 100644 stock_operating_unit/model/stock_quant.py
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index 1a066c8a2f..29581636e9 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -14,13 +14,13 @@ Stock with Operating Units
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
- :target: https://github.com/OCA/operating-unit/tree/14.0/stock_operating_unit
+ :target: https://github.com/OCA/operating-unit/tree/15.0/stock_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/operating-unit-14-0/operating-unit-14-0-stock_operating_unit
+ :target: https://translation.odoo-community.org/projects/operating-unit-15-0/operating-unit-15-0-stock_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/213/14.0
+ :target: https://runbot.odoo-community.org/runbot/213/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -64,7 +64,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -85,6 +85,7 @@ Contributors
* Sudhir Arya
* Nicola Studer
* Kitti U.
+* Alan Ramos
Maintainers
~~~~~~~~~~~
@@ -99,6 +100,6 @@ 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.
-This module is part of the `OCA/operating-unit `_ project on GitHub.
+This module is part of the `OCA/operating-unit `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index 0e28b5386f..a364bdcc8a 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -1,11 +1,11 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "14.0.1.0.2",
+ "version": "15.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
index eac7697edd..7ef2136584 100644
--- a/stock_operating_unit/hooks.py
+++ b/stock_operating_unit/hooks.py
@@ -1,5 +1,5 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import SUPERUSER_ID
from odoo.api import Environment
diff --git a/stock_operating_unit/i18n/stock_operating_unit.pot b/stock_operating_unit/i18n/stock_operating_unit.pot
index ee8fb27a4c..1c39bd1105 100644
--- a/stock_operating_unit/i18n/stock_operating_unit.pot
+++ b/stock_operating_unit/i18n/stock_operating_unit.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 14.0\n"
+"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -91,41 +91,11 @@ msgstr ""
msgid "Dest. Location Operating Unit"
msgstr ""
-#. module: stock_operating_unit
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__display_name
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__display_name
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__display_name
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule__display_name
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__display_name
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse_orderpoint__display_name
-msgid "Display Name"
-msgstr ""
-
-#. module: stock_operating_unit
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__id
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__id
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__id
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule__id
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__id
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse_orderpoint__id
-msgid "ID"
-msgstr ""
-
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_location
msgid "Inventory Locations"
msgstr ""
-#. module: stock_operating_unit
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location____last_update
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move____last_update
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking____last_update
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule____last_update
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse____last_update
-#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse_orderpoint____last_update
-msgid "Last Modified on"
-msgstr ""
-
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
@@ -133,12 +103,18 @@ msgstr ""
#. module: stock_operating_unit
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__operating_unit_id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_quant__operating_unit_id
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule__operating_unit_id
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__operating_unit_id
#: model_terms:ir.ui.view,arch_db:stock_operating_unit.view_picking_internal_search
msgid "Operating Unit"
msgstr ""
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_quant
+msgid "Quants"
+msgstr ""
+
#. module: stock_operating_unit
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__operating_unit_id
msgid "Requesting Operating Unit"
diff --git a/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py b/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
new file mode 100644
index 0000000000..54c0cba681
--- /dev/null
+++ b/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
@@ -0,0 +1,16 @@
+# Copyright 2021 Jarsa
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
+
+
+def migrate(cr, installed_version):
+ cr.execute(
+ "ALTER TABLE stock_quant ADD COLUMN IF NOT EXISTS operating_unit_id int4;"
+ )
+ cr.execute(
+ """
+ UPDATE stock_quant
+ SET operating_unit_id = sl.operating_unit_id
+ FROM stock_location sl
+ WHERE sl.id=location_id AND sl.operating_unit_id IS NOT NULL;
+ """
+ )
diff --git a/stock_operating_unit/model/__init__.py b/stock_operating_unit/model/__init__.py
index 6ddeb2e025..e12a3a3aa1 100644
--- a/stock_operating_unit/model/__init__.py
+++ b/stock_operating_unit/model/__init__.py
@@ -5,3 +5,4 @@
from . import stock_picking
from . import stock_rule
from . import stock_warehouse
+from . import stock_quant
diff --git a/stock_operating_unit/model/stock_location.py b/stock_operating_unit/model/stock_location.py
index 03d37aba2a..d2861bdb4c 100644
--- a/stock_operating_unit/model/stock_location.py
+++ b/stock_operating_unit/model/stock_location.py
@@ -1,5 +1,5 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 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/stock_operating_unit/model/stock_move.py b/stock_operating_unit/model/stock_move.py
index 4406016f6f..a0a5c875b2 100644
--- a/stock_operating_unit/model/stock_move.py
+++ b/stock_operating_unit/model/stock_move.py
@@ -1,5 +1,5 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 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/stock_operating_unit/model/stock_picking.py b/stock_operating_unit/model/stock_picking.py
index 4269ea4c6f..fa5e4cb817 100644
--- a/stock_operating_unit/model/stock_picking.py
+++ b/stock_operating_unit/model/stock_picking.py
@@ -1,5 +1,5 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 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
@@ -16,11 +16,10 @@ class StockPicking(models.Model):
)
@api.onchange("picking_type_id", "partner_id")
- def onchange_picking_type(self):
- res = super(StockPicking, self).onchange_picking_type()
+ def _onchange_picking_type(self):
+ res = super()._onchange_picking_type()
if self.picking_type_id:
- unit = self.picking_type_id.warehouse_id.operating_unit_id
- self.operating_unit_id = unit
+ self.operating_unit_id = self.picking_type_id.warehouse_id.operating_unit_id
return res
@api.constrains("operating_unit_id", "company_id")
diff --git a/stock_operating_unit/model/stock_quant.py b/stock_operating_unit/model/stock_quant.py
new file mode 100644
index 0000000000..fb99254ab4
--- /dev/null
+++ b/stock_operating_unit/model/stock_quant.py
@@ -0,0 +1,12 @@
+# Copyright 2021 Jarsa
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
+from odoo import fields, models
+
+
+class StockQuant(models.Model):
+ _inherit = "stock.quant"
+
+ operating_unit_id = fields.Many2one(
+ related="location_id.operating_unit_id",
+ store=True,
+ )
diff --git a/stock_operating_unit/model/stock_rule.py b/stock_operating_unit/model/stock_rule.py
index 2ba9764be6..bf16538eb4 100644
--- a/stock_operating_unit/model/stock_rule.py
+++ b/stock_operating_unit/model/stock_rule.py
@@ -1,5 +1,5 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 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/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py
index 3404c13eb7..b63e597cbc 100644
--- a/stock_operating_unit/model/stock_warehouse.py
+++ b/stock_operating_unit/model/stock_warehouse.py
@@ -1,5 +1,5 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 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
@@ -46,8 +46,6 @@ class StockWarehouseOrderPoint(models.Model):
@api.constrains(
"warehouse_id",
"location_id",
- "location_id.operating_unit_id",
- "warehouse_id.operating_unit_id",
)
def _check_location(self):
for rec in self:
diff --git a/stock_operating_unit/readme/CONTRIBUTORS.rst b/stock_operating_unit/readme/CONTRIBUTORS.rst
index 882e94eeac..b3b4ed0462 100644
--- a/stock_operating_unit/readme/CONTRIBUTORS.rst
+++ b/stock_operating_unit/readme/CONTRIBUTORS.rst
@@ -3,3 +3,4 @@
* Sudhir Arya
* Nicola Studer
* Kitti U.
+* Alan Ramos
diff --git a/stock_operating_unit/security/stock_security.xml b/stock_operating_unit/security/stock_security.xml
index cb5dd0aec3..ab90ce8f6d 100644
--- a/stock_operating_unit/security/stock_security.xml
+++ b/stock_operating_unit/security/stock_security.xml
@@ -104,11 +104,11 @@
-
+
['|',
- ('location_id.operating_unit_id', '=', False),
- ('location_id.operating_unit_id', 'in', user.operating_unit_ids.ids)]
+ ('operating_unit_id', '=', False),
+ ('operating_unit_id', 'in', user.operating_unit_ids.ids)]
Quants from allowed operating units
diff --git a/stock_operating_unit/static/description/index.html b/stock_operating_unit/static/description/index.html
index e1ea87a724..58a70a3ea2 100644
--- a/stock_operating_unit/static/description/index.html
+++ b/stock_operating_unit/static/description/index.html
@@ -367,7 +367,7 @@ Stock with Operating Units
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module introduces the following features:
- Adds the operating unit to the Warehouse.
@@ -414,7 +414,7 @@
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -443,7 +444,7 @@
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.
-
This module is part of the OCA/operating-unit project on GitHub.
+
This module is part of the OCA/operating-unit project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index f860a3ccff..10c0f387b3 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -1,5 +1,5 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo.addons.stock.tests import common
@@ -65,7 +65,7 @@ def setUp(self):
def _create_user(self, login, groups, company, operating_units):
"""Create a user."""
group_ids = [group.id for group in groups]
- user = self.ResUsers.with_context({"no_reset_password": True}).create(
+ user = self.ResUsers.with_context(**{"no_reset_password": True}).create(
{
"name": "Stock User",
"login": login,
diff --git a/stock_operating_unit/tests/test_stock_picking.py b/stock_operating_unit/tests/test_stock_picking.py
index 7416a6f5b4..178f709ae6 100644
--- a/stock_operating_unit/tests/test_stock_picking.py
+++ b/stock_operating_unit/tests/test_stock_picking.py
@@ -1,9 +1,13 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
+
+from odoo.tests import tagged
+
from . import test_stock_operating_unit as test_stock_ou
+@tagged("post_install", "-at_install")
class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
def test_stock_picking_ou(self):
"""Test Pickings of Stock Operating Unit"""
diff --git a/stock_operating_unit/tests/test_stock_security.py b/stock_operating_unit/tests/test_stock_security.py
index d20f3318c4..21aeb2fe88 100644
--- a/stock_operating_unit/tests/test_stock_security.py
+++ b/stock_operating_unit/tests/test_stock_security.py
@@ -1,9 +1,13 @@
-# © 2019 ForgeFlow S.L.
-# © 2019 Serpent Consulting Services Pvt. Ltd.
+# Copyright 2019 ForgeFlow S.L.
+# Copyright 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
+
+from odoo.tests import tagged
+
from . import test_stock_operating_unit as test_stock_ou
+@tagged("post_install", "-at_install")
class TestStockPicking(test_stock_ou.TestStockOperatingUnit):
def test_stock_ou_security(self):
"""Test Security of Stock Operating Unit"""
From 6592b6425e22b04a15039d1a24c02de09daa48cd Mon Sep 17 00:00:00 2001
From: Ignacio Buioli
Date: Sat, 6 Aug 2022 17:53:21 +0000
Subject: [PATCH 35/49] Added translation using Weblate (Spanish (Argentina))
---
stock_operating_unit/i18n/es_AR.po | 147 +++++++++++++++++++++++++++++
1 file changed, 147 insertions(+)
create mode 100644 stock_operating_unit/i18n/es_AR.po
diff --git a/stock_operating_unit/i18n/es_AR.po b/stock_operating_unit/i18n/es_AR.po
new file mode 100644
index 0000000000..054c0ee31c
--- /dev/null
+++ b/stock_operating_unit/i18n/es_AR.po
@@ -0,0 +1,147 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * stock_operating_unit
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 15.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: Automatically generated\n"
+"Language-Team: none\n"
+"Language: es_AR\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
+#, python-format
+msgid ""
+"Configuration Error. The Operating Unit of the Warehouse and the Location "
+"must be the same. "
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:0
+#, python-format
+msgid ""
+"Configuration error. The Company in the Stock Location and in the Operating "
+"Unit must be the same."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_picking.py:0
+#, python-format
+msgid ""
+"Configuration error. The Company in the Stock Picking and in the Operating "
+"Unit must be the same."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
+#, python-format
+msgid ""
+"Configuration error. The Company in the Stock Warehouse and in the Operating"
+" Unit must be the same."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_picking.py:0
+#, python-format
+msgid ""
+"Configuration error. The Operating Unit of the picking must be the same as "
+"that of the warehouse of the Picking Type."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:0
+#, python-format
+msgid ""
+"Configuration error. The Parent Stock Location must belong to the same "
+"Operating Unit."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_move.py:0
+#, python-format
+msgid ""
+"Configuration error. The Stock moves must be related to a location (source "
+"or destination) that belongs to the requesting Operating Unit."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:0
+#: code:addons/stock_operating_unit/model/stock_location.py:0
+#, python-format
+msgid ""
+"Configuration error. The operating unit should be assigned to internal "
+"locations only."
+msgstr ""
+
+#. module: stock_operating_unit
+#: code:addons/stock_operating_unit/model/stock_location.py:0
+#, python-format
+msgid ""
+"Configuration error. This location is assigned to a warehouse that belongs "
+"to a different operating unit."
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__operating_unit_dest_id
+msgid "Dest. Location Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_location
+msgid "Inventory Locations"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_warehouse_orderpoint
+msgid "Minimum Inventory Rule"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__operating_unit_id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_quant__operating_unit_id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_rule__operating_unit_id
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__operating_unit_id
+#: model_terms:ir.ui.view,arch_db:stock_operating_unit.view_picking_internal_search
+msgid "Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_quant
+msgid "Quants"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__operating_unit_id
+msgid "Requesting Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__operating_unit_id
+msgid "Source Location Operating Unit"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_move
+msgid "Stock Move"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_rule
+msgid "Stock Rule"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_picking
+msgid "Transfer"
+msgstr ""
+
+#. module: stock_operating_unit
+#: model:ir.model,name:stock_operating_unit.model_stock_warehouse
+msgid "Warehouse"
+msgstr ""
From 965741432163e29bf42f73a74dfc800b230fa0a0 Mon Sep 17 00:00:00 2001
From: Ignacio Buioli
Date: Sat, 6 Aug 2022 18:17:51 +0000
Subject: [PATCH 36/49] Translated using Weblate (Spanish (Argentina))
Currently translated at 100.0% (20 of 20 strings)
Translation: operating-unit-15.0/operating-unit-15.0-stock_operating_unit
Translate-URL: https://translation.odoo-community.org/projects/operating-unit-15-0/operating-unit-15-0-stock_operating_unit/es_AR/
---
stock_operating_unit/i18n/es_AR.po | 45 ++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 12 deletions(-)
diff --git a/stock_operating_unit/i18n/es_AR.po b/stock_operating_unit/i18n/es_AR.po
index 054c0ee31c..574fe4bf21 100644
--- a/stock_operating_unit/i18n/es_AR.po
+++ b/stock_operating_unit/i18n/es_AR.po
@@ -6,13 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2022-08-06 20:07+0000\n"
+"Last-Translator: Ignacio Buioli \n"
"Language-Team: none\n"
"Language: es_AR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Weblate 4.3.2\n"
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
@@ -21,6 +23,8 @@ msgid ""
"Configuration Error. The Operating Unit of the Warehouse and the Location "
"must be the same. "
msgstr ""
+"Error de Configuración. La Unidad Operativa del Almacén y la Ubicación debe "
+"ser la misma. "
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_location.py:0
@@ -29,6 +33,8 @@ msgid ""
"Configuration error. The Company in the Stock Location and in the Operating "
"Unit must be the same."
msgstr ""
+"Error de Configuración. La Compañía en la Ubicación de Inventario y en la "
+"Unidad Operativa debe ser la misma."
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_picking.py:0
@@ -37,6 +43,8 @@ msgid ""
"Configuration error. The Company in the Stock Picking and in the Operating "
"Unit must be the same."
msgstr ""
+"Error de Configuración. La Compañía en la Transferencia de Inventario y en "
+"la Unidad Operativa debe ser la misma."
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
@@ -45,6 +53,8 @@ msgid ""
"Configuration error. The Company in the Stock Warehouse and in the Operating"
" Unit must be the same."
msgstr ""
+"Error de Configuración. La Compañía en el Almacén de Inventario y en la "
+"Unidad Operativa debe ser la misma."
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_picking.py:0
@@ -53,6 +63,8 @@ msgid ""
"Configuration error. The Operating Unit of the picking must be the same as "
"that of the warehouse of the Picking Type."
msgstr ""
+"Error de Configuración. La Unidad Operativa de la transferencia debe ser la "
+"misma que la del almacén del Tipo de Transferencia."
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_location.py:0
@@ -61,6 +73,8 @@ msgid ""
"Configuration error. The Parent Stock Location must belong to the same "
"Operating Unit."
msgstr ""
+"Error de Configuración. La Ubicación de Inventario principal debe pertenecer "
+"a la misma Unidad Operativa."
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_move.py:0
@@ -69,6 +83,9 @@ msgid ""
"Configuration error. The Stock moves must be related to a location (source "
"or destination) that belongs to the requesting Operating Unit."
msgstr ""
+"Error de Configuración. Los Movimientos de Inventario debe estar "
+"relacionados a una ubicación (origen o destino) que pertenezca a la Unidad "
+"Operativa solicitada."
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_location.py:0
@@ -78,6 +95,8 @@ msgid ""
"Configuration error. The operating unit should be assigned to internal "
"locations only."
msgstr ""
+"Error de Configuración. La unidad operativa debe ser asignada solo a "
+"ubicaciones internas."
#. module: stock_operating_unit
#: code:addons/stock_operating_unit/model/stock_location.py:0
@@ -86,21 +105,23 @@ msgid ""
"Configuration error. This location is assigned to a warehouse that belongs "
"to a different operating unit."
msgstr ""
+"Error de Configuración. Esta ubicación es asignada al almacén que pertenece "
+"a una unidad operativa diferente."
#. module: stock_operating_unit
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__operating_unit_dest_id
msgid "Dest. Location Operating Unit"
-msgstr ""
+msgstr "Ubicación de Destino de la Unidad Operativa"
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_location
msgid "Inventory Locations"
-msgstr ""
+msgstr "Ubicaciones de Inventario"
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
-msgstr ""
+msgstr "Regla de Inventario Mínimo"
#. module: stock_operating_unit
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_location__operating_unit_id
@@ -109,39 +130,39 @@ msgstr ""
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_warehouse__operating_unit_id
#: model_terms:ir.ui.view,arch_db:stock_operating_unit.view_picking_internal_search
msgid "Operating Unit"
-msgstr ""
+msgstr "Unidad Operativa"
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_quant
msgid "Quants"
-msgstr ""
+msgstr "Quants"
#. module: stock_operating_unit
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_picking__operating_unit_id
msgid "Requesting Operating Unit"
-msgstr ""
+msgstr "Unidad Operativa Solicitante"
#. module: stock_operating_unit
#: model:ir.model.fields,field_description:stock_operating_unit.field_stock_move__operating_unit_id
msgid "Source Location Operating Unit"
-msgstr ""
+msgstr "Ubicación de Origen de la Unidad Operativa"
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_move
msgid "Stock Move"
-msgstr ""
+msgstr "Movimiento de Inventario"
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_rule
msgid "Stock Rule"
-msgstr ""
+msgstr "Regla de Inventario"
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_picking
msgid "Transfer"
-msgstr ""
+msgstr "Transferir"
#. module: stock_operating_unit
#: model:ir.model,name:stock_operating_unit.model_stock_warehouse
msgid "Warehouse"
-msgstr ""
+msgstr "Almacén"
From 21b1973370004880286297af0b6014553aaa223a Mon Sep 17 00:00:00 2001
From: Saran440
Date: Fri, 3 Mar 2023 15:17:24 +0700
Subject: [PATCH 37/49] [FIX] stock_operating_unit: filter domain users out
---
stock_operating_unit/__manifest__.py | 2 +-
stock_operating_unit/model/stock_location.py | 5 ++++-
stock_operating_unit/model/stock_picking.py | 4 ++--
stock_operating_unit/model/stock_rule.py | 3 +--
stock_operating_unit/view/stock.xml | 22 +++-----------------
5 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index a364bdcc8a..bfe9b1436c 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "15.0.1.0.0",
+ "version": "15.0.1.1.0",
"category": "Generic Modules/Sales & Purchases",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/model/stock_location.py b/stock_operating_unit/model/stock_location.py
index d2861bdb4c..4fcb4ba49e 100644
--- a/stock_operating_unit/model/stock_location.py
+++ b/stock_operating_unit/model/stock_location.py
@@ -8,7 +8,10 @@
class StockLocation(models.Model):
_inherit = "stock.location"
- operating_unit_id = fields.Many2one("operating.unit", "Operating Unit")
+ operating_unit_id = fields.Many2one(
+ comodel_name="operating.unit",
+ string="Operating Unit",
+ )
@api.constrains("operating_unit_id")
def _check_warehouse_operating_unit(self):
diff --git a/stock_operating_unit/model/stock_picking.py b/stock_operating_unit/model/stock_picking.py
index fa5e4cb817..f4955a9ae8 100644
--- a/stock_operating_unit/model/stock_picking.py
+++ b/stock_operating_unit/model/stock_picking.py
@@ -9,8 +9,8 @@ class StockPicking(models.Model):
_inherit = "stock.picking"
operating_unit_id = fields.Many2one(
- "operating.unit",
- "Requesting Operating Unit",
+ comodel_name="operating.unit",
+ string="Requesting Operating Unit",
readonly=True,
states={"draft": [("readonly", False)]},
)
diff --git a/stock_operating_unit/model/stock_rule.py b/stock_operating_unit/model/stock_rule.py
index bf16538eb4..a99ad03997 100644
--- a/stock_operating_unit/model/stock_rule.py
+++ b/stock_operating_unit/model/stock_rule.py
@@ -9,7 +9,6 @@ class StockRule(models.Model):
_inherit = "stock.rule"
operating_unit_id = fields.Many2one(
- "operating.unit",
+ comodel_name="operating.unit",
related="warehouse_id.operating_unit_id",
- domain="[('user_ids', '=', uid)]",
)
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index d9ae07fc9b..f09e82677b 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -12,8 +12,7 @@
@@ -27,7 +26,6 @@
@@ -42,8 +40,7 @@
@@ -57,7 +54,6 @@
@@ -71,7 +67,6 @@
@@ -85,7 +80,6 @@
@@ -103,8 +97,7 @@
@@ -123,7 +116,6 @@
@@ -145,14 +137,12 @@
@@ -166,14 +156,12 @@
@@ -187,14 +175,12 @@
@@ -208,14 +194,12 @@
From 3f32f156f0eb3133641e8330db5827cce21d4508 Mon Sep 17 00:00:00 2001
From: ps-tubtim
Date: Thu, 9 Mar 2023 17:00:04 +0700
Subject: [PATCH 38/49] [FIX] stock_operating_unit: remove domain of operation
type
---
stock_operating_unit/__manifest__.py | 2 +-
stock_operating_unit/view/stock.xml | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index bfe9b1436c..e361272bc1 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "15.0.1.1.0",
+ "version": "15.0.1.2.0",
"category": "Generic Modules/Sales & Purchases",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
diff --git a/stock_operating_unit/view/stock.xml b/stock_operating_unit/view/stock.xml
index f09e82677b..890a4b2a6a 100644
--- a/stock_operating_unit/view/stock.xml
+++ b/stock_operating_unit/view/stock.xml
@@ -101,11 +101,6 @@
groups="operating_unit.group_multi_operating_unit"
/>
-
- [('warehouse_id.operating_unit_id.user_ids', 'in', uid)]
-
From 5bfe939b8bda69fac56c14db95f0d87c2dc32e66 Mon Sep 17 00:00:00 2001
From: AaronHForgeFlow
Date: Tue, 23 May 2023 09:47:19 +0200
Subject: [PATCH 39/49] [FIX] stock_operating_unit: migration script to 15.0
---
stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py b/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
index 54c0cba681..f0cabe477b 100644
--- a/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
+++ b/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
@@ -11,6 +11,6 @@ def migrate(cr, installed_version):
UPDATE stock_quant
SET operating_unit_id = sl.operating_unit_id
FROM stock_location sl
- WHERE sl.id=location_id AND sl.operating_unit_id IS NOT NULL;
+ WHERE sl.id=stock_quant.location_id AND sl.operating_unit_id IS NOT NULL;
"""
)
From f03b07be9631d06c6b727efe94d05dcb2c2fb33f Mon Sep 17 00:00:00 2001
From: Borruso
Date: Thu, 22 Jun 2023 08:59:40 +0200
Subject: [PATCH 40/49] [MIG] stock_operating_unit: Migration to 16.0
---
stock_operating_unit/README.rst | 23 +++++----
stock_operating_unit/__init__.py | 1 -
stock_operating_unit/__manifest__.py | 3 +-
stock_operating_unit/hooks.py | 23 ---------
stock_operating_unit/i18n/es_AR.po | 14 ++++--
.../i18n/stock_operating_unit.pot | 11 +++-
.../migrations/15.0.1.0.0/pre-migration.py | 16 ------
.../static/description/index.html | 50 ++++++++++---------
8 files changed, 61 insertions(+), 80 deletions(-)
delete mode 100644 stock_operating_unit/hooks.py
delete mode 100644 stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst
index 29581636e9..aa28aa4856 100644
--- a/stock_operating_unit/README.rst
+++ b/stock_operating_unit/README.rst
@@ -2,10 +2,13 @@
Stock with Operating Units
==========================
-.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+..
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! source digest: sha256:7e8e6e6d93a862e3e6920f8e85abc4aac9c6c63ba34a91d8cf2683e3e7428f63
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
@@ -14,16 +17,16 @@ Stock with Operating Units
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
- :target: https://github.com/OCA/operating-unit/tree/15.0/stock_operating_unit
+ :target: https://github.com/OCA/operating-unit/tree/16.0/stock_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/operating-unit-15-0/operating-unit-15-0-stock_operating_unit
+ :target: https://translation.odoo-community.org/projects/operating-unit-16-0/operating-unit-16-0-stock_operating_unit
:alt: Translate me on Weblate
-.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/213/15.0
- :alt: Try me on Runbot
+.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&target_branch=16.0
+ :alt: Try me on Runboat
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
This module introduces the following features:
@@ -63,8 +66,8 @@ 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 `_.
+If you spotted it first, help us to smash it by providing a detailed and welcomed
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -100,6 +103,6 @@ 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.
-This module is part of the `OCA/operating-unit `_ project on GitHub.
+This module is part of the `OCA/operating-unit `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_operating_unit/__init__.py b/stock_operating_unit/__init__.py
index 122296e393..3bbf81aeec 100644
--- a/stock_operating_unit/__init__.py
+++ b/stock_operating_unit/__init__.py
@@ -1,4 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import model
-from .hooks import update_operating_unit_location
diff --git a/stock_operating_unit/__manifest__.py b/stock_operating_unit/__manifest__.py
index e361272bc1..a09f86fde8 100644
--- a/stock_operating_unit/__manifest__.py
+++ b/stock_operating_unit/__manifest__.py
@@ -5,7 +5,7 @@
{
"name": "Stock with Operating Units",
"summary": "Adds the concept of operating unit (OU) in stock management",
- "version": "15.0.1.2.0",
+ "version": "16.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd., "
@@ -16,5 +16,4 @@
"data": ["security/stock_security.xml", "data/stock_data.xml", "view/stock.xml"],
"demo": ["demo/stock_demo.xml"],
"installable": True,
- "post_init_hook": "update_operating_unit_location",
}
diff --git a/stock_operating_unit/hooks.py b/stock_operating_unit/hooks.py
deleted file mode 100644
index 7ef2136584..0000000000
--- a/stock_operating_unit/hooks.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2019 ForgeFlow S.L.
-# Copyright 2019 Serpent Consulting Services Pvt. Ltd.
-# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
-from odoo import SUPERUSER_ID
-from odoo.api import Environment
-
-
-def update_operating_unit_location(cr, registry):
- env = Environment(cr, SUPERUSER_ID, {})
- warehouses = env["stock.warehouse"].search([])
- for warehouse in warehouses:
- operating_unit = warehouse.operating_unit_id
- parent_location = warehouse.view_location_id
- locations = env["stock.location"].search(
- [("id", "child_of", [parent_location.id]), ("usage", "=", "internal")]
- )
- if operating_unit:
- query = """update stock_location set operating_unit_id = %s where
- location_id in %s or id in %s"""
- cr.execute(
- query, (operating_unit.id, tuple(locations.ids), tuple(locations.ids))
- )
- return True
diff --git a/stock_operating_unit/i18n/es_AR.po b/stock_operating_unit/i18n/es_AR.po
index 574fe4bf21..49b34e793f 100644
--- a/stock_operating_unit/i18n/es_AR.po
+++ b/stock_operating_unit/i18n/es_AR.po
@@ -17,6 +17,7 @@ msgstr ""
"X-Generator: Weblate 4.3.2\n"
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
#, python-format
msgid ""
@@ -27,6 +28,7 @@ msgstr ""
"ser la misma. "
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
msgid ""
@@ -37,6 +39,7 @@ msgstr ""
"Unidad Operativa debe ser la misma."
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_picking.py:0
#, python-format
msgid ""
@@ -47,16 +50,18 @@ msgstr ""
"la Unidad Operativa debe ser la misma."
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
#, python-format
msgid ""
-"Configuration error. The Company in the Stock Warehouse and in the Operating"
-" Unit must be the same."
+"Configuration error. The Company in the Stock Warehouse and in the Operating "
+"Unit must be the same."
msgstr ""
"Error de Configuración. La Compañía en el Almacén de Inventario y en la "
"Unidad Operativa debe ser la misma."
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_picking.py:0
#, python-format
msgid ""
@@ -67,6 +72,7 @@ msgstr ""
"misma que la del almacén del Tipo de Transferencia."
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
msgid ""
@@ -77,6 +83,7 @@ msgstr ""
"a la misma Unidad Operativa."
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_move.py:0
#, python-format
msgid ""
@@ -88,7 +95,7 @@ msgstr ""
"Operativa solicitada."
#. module: stock_operating_unit
-#: code:addons/stock_operating_unit/model/stock_location.py:0
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
msgid ""
@@ -99,6 +106,7 @@ msgstr ""
"ubicaciones internas."
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
msgid ""
diff --git a/stock_operating_unit/i18n/stock_operating_unit.pot b/stock_operating_unit/i18n/stock_operating_unit.pot
index 1c39bd1105..2d4338472a 100644
--- a/stock_operating_unit/i18n/stock_operating_unit.pot
+++ b/stock_operating_unit/i18n/stock_operating_unit.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 15.0\n"
+"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -14,6 +14,7 @@ msgstr ""
"Plural-Forms: \n"
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
#, python-format
msgid ""
@@ -22,6 +23,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
msgid ""
@@ -30,6 +32,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_picking.py:0
#, python-format
msgid ""
@@ -38,6 +41,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_warehouse.py:0
#, python-format
msgid ""
@@ -46,6 +50,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_picking.py:0
#, python-format
msgid ""
@@ -54,6 +59,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
msgid ""
@@ -62,6 +68,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_move.py:0
#, python-format
msgid ""
@@ -70,6 +77,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
@@ -79,6 +87,7 @@ msgid ""
msgstr ""
#. module: stock_operating_unit
+#. odoo-python
#: code:addons/stock_operating_unit/model/stock_location.py:0
#, python-format
msgid ""
diff --git a/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py b/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
deleted file mode 100644
index f0cabe477b..0000000000
--- a/stock_operating_unit/migrations/15.0.1.0.0/pre-migration.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2021 Jarsa
-# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
-
-
-def migrate(cr, installed_version):
- cr.execute(
- "ALTER TABLE stock_quant ADD COLUMN IF NOT EXISTS operating_unit_id int4;"
- )
- cr.execute(
- """
- UPDATE stock_quant
- SET operating_unit_id = sl.operating_unit_id
- FROM stock_location sl
- WHERE sl.id=stock_quant.location_id AND sl.operating_unit_id IS NOT NULL;
- """
- )
diff --git a/stock_operating_unit/static/description/index.html b/stock_operating_unit/static/description/index.html
index 58a70a3ea2..a0ed468e27 100644
--- a/stock_operating_unit/static/description/index.html
+++ b/stock_operating_unit/static/description/index.html
@@ -1,20 +1,20 @@
-
+
-
+
Stock with Operating Units
-
-
Stock with Operating Units
+
+
+
+
+
+
-
+
To configure this module, you need to:
- Assign Operating Unit to Warehouses.
@@ -401,35 +406,35 @@
-
+
This module defines the operating unit entity and the user’s security
rules. Other modules extend the standard Odoo apps with the OU.
-
+
The Manager can see the stock rules of other Operating Units but he can
not edit them. If he tries to access to one of these stock rules, he
will receive a configuration error.
-
+
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 to smash it by providing a detailed and welcomed
-feedback.
+
feedback.
Do not contact contributors directly about support or help with technical issues.
-
+
-
+
- ForgeFlow
- Serpent Consulting Services Pvt. Ltd.
+
diff --git a/stock_operating_unit/tests/test_stock_operating_unit.py b/stock_operating_unit/tests/test_stock_operating_unit.py
index 4cd92ea873..89b09ff00b 100644
--- a/stock_operating_unit/tests/test_stock_operating_unit.py
+++ b/stock_operating_unit/tests/test_stock_operating_unit.py
@@ -1,7 +1,7 @@
# Copyright 2019 ForgeFlow S.L.
# Copyright 2019 Serpent Consulting Services Pvt. Ltd.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
-from odoo.models import Command
+from odoo.fields import Command
from odoo.addons.operating_unit.tests.common import OperatingUnitCommon
from odoo.addons.stock.tests import common
@@ -17,11 +17,40 @@ def setUpClass(cls):
# groups
cls.group_stock_manager = cls.env.ref("stock.group_stock_manager")
# Products
- cls.product1 = cls.env.ref("product.product_product_7")
- cls.product2 = cls.env.ref("product.product_product_9")
- cls.product3 = cls.env.ref("product.product_product_11")
+ cls.product1 = cls.env["product.product"].create(
+ {
+ "name": "Storage Box Test",
+ "standard_price": 14.0,
+ "list_price": 15.8,
+ "type": "consu",
+ }
+ )
+ cls.product2 = cls.env["product.product"].create(
+ {
+ "name": "Pedal Bin Test",
+ "standard_price": 10.0,
+ "list_price": 47.0,
+ "type": "consu",
+ }
+ )
+ cls.product3 = cls.env["product.product"].create(
+ {
+ "name": "Conference Chair Test",
+ "standard_price": 28.0,
+ "list_price": 33.0,
+ "type": "consu",
+ }
+ )
# Locations
- cls.b2c_wh = cls.env.ref("stock_operating_unit.stock_warehouse_b2c")
+ cls.b2c_wh = cls.env["stock.warehouse"].create(
+ {
+ "name": "B2C Warehouse Test",
+ "code": "B2C_Test",
+ "partner_id": cls.partner.id,
+ "company_id": cls.company.id,
+ "operating_unit_id": cls.b2c.id,
+ }
+ )
cls.b2c_wh.lot_stock_id.write({"operating_unit_id": cls.b2c.id})
cls.location_b2c_id = cls.b2c_wh.lot_stock_id.id
cls.b2c_type_in_id = cls.b2c_wh.in_type_id.id
@@ -29,7 +58,7 @@ def setUpClass(cls):
# Update users
cls.user1.write(
{
- "groups_id": [
+ "group_ids": [
Command.link(cls.group_stock_manager.id),
],
"operating_unit_ids": [
@@ -40,7 +69,7 @@ def setUpClass(cls):
)
cls.user2.write(
{
- "groups_id": [
+ "group_ids": [
Command.link(cls.group_stock_manager.id),
],
"operating_unit_ids": [
@@ -53,14 +82,14 @@ def setUpClass(cls):
cls.user1,
cls.b2c.id,
cls.b2c_type_in_id,
- cls.supplier_location,
- cls.stock_location,
+ cls.supplier_location.id,
+ cls.stock_location.id,
)
cls.picking_in2 = cls._create_picking(
cls.user2,
cls.b2c.id,
cls.b2c_type_in_id,
- cls.supplier_location,
+ cls.supplier_location.id,
cls.location_b2c_id,
)
# Create Internal Shipment
@@ -68,7 +97,7 @@ def setUpClass(cls):
cls.user1,
cls.b2c.id,
cls.b2c_type_int_id,
- cls.stock_location,
+ cls.stock_location.id,
cls.location_b2c_id,
)
@@ -85,7 +114,6 @@ def _create_picking(cls, user_id, ou_id, picking_type, src_loc_id, dest_loc_id):
)
cls.MoveObj.with_user(user_id).create(
{
- "name": "a move",
"product_id": cls.productA.id,
"product_uom_qty": 3.0,
"product_uom": cls.productA.uom_id.id,