diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/point_of_sale/models/stock_warehouse.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/point_of_sale/models/stock_warehouse.py')
| -rw-r--r-- | addons/point_of_sale/models/stock_warehouse.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/addons/point_of_sale/models/stock_warehouse.py b/addons/point_of_sale/models/stock_warehouse.py new file mode 100644 index 00000000..f0058b32 --- /dev/null +++ b/addons/point_of_sale/models/stock_warehouse.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api, _ + + +class Warehouse(models.Model): + _inherit = "stock.warehouse" + + pos_type_id = fields.Many2one('stock.picking.type', string="Point of Sale Operation Type") + + def _get_sequence_values(self): + sequence_values = super(Warehouse, self)._get_sequence_values() + sequence_values.update({ + 'pos_type_id': { + 'name': self.name + ' ' + _('Picking POS'), + 'prefix': self.code + '/POS/', + 'padding': 5, + 'company_id': self.company_id.id, + } + }) + return sequence_values + + def _get_picking_type_update_values(self): + picking_type_update_values = super(Warehouse, self)._get_picking_type_update_values() + picking_type_update_values.update({ + 'pos_type_id': {'default_location_src_id': self.lot_stock_id.id} + }) + return picking_type_update_values + + def _get_picking_type_create_values(self, max_sequence): + picking_type_create_values, max_sequence = super(Warehouse, self)._get_picking_type_create_values(max_sequence) + picking_type_create_values.update({ + 'pos_type_id': { + 'name': _('PoS Orders'), + 'code': 'outgoing', + 'default_location_src_id': self.lot_stock_id.id, + 'default_location_dest_id': self.env.ref('stock.stock_location_customers').id, + 'sequence': max_sequence + 1, + 'sequence_code': 'POS', + 'company_id': self.company_id.id, + 'show_operations': False, + } + }) + return picking_type_create_values, max_sequence + 2 + + @api.model + def _create_missing_pos_picking_types(self): + warehouses = self.env['stock.warehouse'].search([('pos_type_id', '=', False)]) + for warehouse in warehouses: + new_vals = warehouse._create_or_update_sequences_and_picking_types() + warehouse.write(new_vals) |
