Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE][IMP] stock: Add a prepare method to easier update value in the future #68

Open
wants to merge 1 commit into
base: 13.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions addons/stock/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ def _compute_warehouse_count(self):
def _compute_show_resupply(self):
for warehouse in self:
warehouse.show_resupply = warehouse.user_has_groups("stock.group_stock_multi_warehouses") and warehouse.warehouse_count


def _prepare_loc_values(self, vals):
return {'name': _(vals.get('code')), 'usage': 'view',
'location_id': self.env.ref('stock.stock_location_locations').id}

@api.model
def create(self, vals):
# create view location for warehouse then create all locations
loc_vals = {'name': _(vals.get('code')), 'usage': 'view',
'location_id': self.env.ref('stock.stock_location_locations').id}
loc_vals = self._prepare_loc_values(vals)
if vals.get('company_id'):
loc_vals['company_id'] = vals.get('company_id')
vals['view_location_id'] = self.env['stock.location'].create(loc_vals).id
Expand Down