diff options
| author | Antoine Vandevenne (anv) <anv@odoo.com> | 2019-05-03 09:57:18 +0000 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2019-06-03 12:09:26 +0000 |
| commit | 8e30349fd1f2baffd47e50106eddbd1c59979aaf (patch) | |
| tree | 7566e4fb3e32447116510635b4aaf5ad01941504 /addons | |
| parent | a681631dd094cb261161ff4aa89686969ba5bb37 (diff) | |
[REF] point_of_sale: remove stock location from POS config
There is currently a stock location that is set on the pos config which
is by default the the default source of the picking type. This field is
not really usefull and we prefer that the configuration of the source
location where the POS will take products come from a dedicated
picking type that will have the correct default source location.
So we have removed the stock_location_id from the pos_config and changed
the related set on orders, by the location of the picking set on the
pos order, as it was not really consistent that if the pos_config was
changed the location of all existing orders was changed too.
TASK-ID: 1970513
closes odoo/odoo#32870
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/point_of_sale/models/pos_config.py | 19 | ||||
| -rw-r--r-- | addons/point_of_sale/models/pos_order.py | 4 | ||||
| -rw-r--r-- | addons/point_of_sale/static/src/js/models.js | 10 | ||||
| -rw-r--r-- | addons/point_of_sale/views/pos_config_view.xml | 18 |
4 files changed, 7 insertions, 44 deletions
diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 34040fff1c4..8583762a700 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -40,7 +40,7 @@ class PosConfig(models.Model): _description = 'Point of Sale Configuration' def _default_picking_type_id(self): - return self.env['stock.warehouse'].search([('company_id', '=', self.env.user.company_id.id)], limit=1).pos_type_id.id + return self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1).pos_type_id.id def _default_sale_journal(self): journal = self.env.ref('point_of_sale.pos_sale_journal', raise_if_not_found=False) @@ -54,9 +54,6 @@ class PosConfig(models.Model): def _default_pricelist(self): return self.env['product.pricelist'].search([('currency_id', '=', self.env.company.currency_id.id)], limit=1) - def _get_default_location(self): - return self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1).lot_stock_id - def _get_group_pos_manager(self): return self.env.ref('point_of_sale.group_pos_manager') @@ -79,9 +76,6 @@ class PosConfig(models.Model): default=_default_picking_type_id, domain="[('code', '=', 'outgoing'), ('warehouse_id.company_id', '=', company_id)]") use_existing_lots = fields.Boolean(related='picking_type_id.use_existing_lots', readonly=False) - stock_location_id = fields.Many2one( - 'stock.location', string='Stock Location', - domain=[('usage', '=', 'internal')], required=True, default=_get_default_location) journal_id = fields.Many2one( 'account.journal', string='Sales Journal', domain=[('type', '=', 'sale')], @@ -227,11 +221,6 @@ class PosConfig(models.Model): pos_config.pos_session_state = False pos_config.pos_session_duration = 0 - @api.constrains('company_id', 'stock_location_id') - def _check_company_location(self): - if self.stock_location_id.company_id and self.stock_location_id.company_id.id != self.company_id.id: - raise ValidationError(_("The stock location and the point of sale must belong to the same company.")) - @api.constrains('company_id', 'journal_id') def _check_company_journal(self): if self.journal_id and self.journal_id.company_id.id != self.company_id.id: @@ -274,11 +263,6 @@ class PosConfig(models.Model): if self.module_account: self.invoice_journal_id = self.env.ref('point_of_sale.pos_sale_journal') - @api.onchange('picking_type_id') - def _onchange_picking_type_id(self): - if self.picking_type_id.default_location_src_id.usage == 'internal' and self.picking_type_id.default_location_dest_id.usage == 'customer': - self.stock_location_id = self.picking_type_id.default_location_src_id.id - @api.onchange('use_pricelist') def _onchange_use_pricelist(self): """ @@ -448,7 +432,6 @@ class PosConfig(models.Model): """ self.ensure_one() if not self.current_session_id: - self._check_company_location() self._check_company_journal() self._check_company_invoice_journal() self._check_company_payment() diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 33e7f55ee28..2765edfb8e1 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -573,7 +573,7 @@ class PosOrder(models.Model): picking_type_id = fields.Many2one('stock.picking.type', related='session_id.config_id.picking_type_id', string="Operation Type", readonly=False) location_id = fields.Many2one( comodel_name='stock.location', - related='session_id.config_id.stock_location_id', + related='picking_id.location_id', string="Location", store=True, readonly=True, ) @@ -793,7 +793,7 @@ class PosOrder(models.Model): order_picking = Picking return_picking = Picking moves = Move - location_id = order.location_id.id + location_id = picking_type.default_location_src_id.id if order.partner_id: destination_id = order.partner_id.property_stock_customer.id else: diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 37fd3621ce2..5cf80e1e64d 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -51,7 +51,6 @@ exports.PosModel = Backbone.Model.extend({ this.company_logo = null; this.company_logo_base64 = ''; this.currency = null; - this.shop = null; this.company = null; this.user = null; this.users = []; @@ -279,11 +278,6 @@ exports.PosModel = Backbone.Model.extend({ } }, },{ - model: 'stock.location', - fields: [], - ids: function(self){ return [self.config.stock_location_id[0]]; }, - loaded: function(self, locations){ self.shop = locations[0]; }, - },{ model: 'product.pricelist', fields: ['name', 'display_name', 'discount_policy'], domain: function(self) { return [['id', 'in', self.config.available_pricelist_ids]]; }, @@ -2243,7 +2237,6 @@ exports.Order = Backbone.Model.extend({ var client = this.get('client'); var cashier = this.pos.get_cashier(); var company = this.pos.company; - var shop = this.pos.shop; var date = new Date(); function is_xml(subreceipt){ @@ -2305,9 +2298,6 @@ exports.Order = Backbone.Model.extend({ phone: company.phone, logo: this.pos.company_logo_base64, }, - shop:{ - name: shop.name, - }, currency: this.pos.currency, }; diff --git a/addons/point_of_sale/views/pos_config_view.xml b/addons/point_of_sale/views/pos_config_view.xml index 2de6a00172c..8ccac51c746 100644 --- a/addons/point_of_sale/views/pos_config_view.xml +++ b/addons/point_of_sale/views/pos_config_view.xml @@ -457,24 +457,14 @@ <div class="o_setting_right_pane"> <label for="picking_type_id" string="Operation Type"/> <div class="text-muted"> - Operation type used to record product pickings + Operation type used to record product pickings <br/> + Products will be taken from the default source location of this operation type </div> <div class="content-group mt16"> <field name="picking_type_id" required="1"/> </div> </div> </div> - <div class="col-12 col-lg-6 o_setting_box" groups="stock.group_stock_multi_locations"> - <div class="o_setting_right_pane"> - <label for="stock_location_id"/> - <div class="text-muted"> - Stock location used for the inventory - </div> - <div> - <field name="stock_location_id" options="{'no_create': True}"/> - </div> - </div> - </div> </div> <h2>Accounting</h2> <div class="row mt16 o_settings_container" id="accounting_section"> @@ -509,7 +499,7 @@ <field name="arch" type="xml"> <tree string="Point of Sale Configuration"> <field name="name" /> - <field name="stock_location_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/> + <field name="picking_type_id"/> </tree> </field> </record> @@ -521,7 +511,7 @@ <search string="Point of Sale Config"> <field name="name"/> <filter string="Inactive" name="inactive" domain="[('active', '=', False)]" /> - <field name="stock_location_id" groups="stock.group_stock_multi_locations" /> + <field name="picking_type_id" /> </search> </field> </record> |
