Skip to content

Commit

Permalink
[FIX] point_of_sale: set archived warehouse for pos type
Browse files Browse the repository at this point in the history
Found error during migration in customer database.
when company is archived but will get that company
on `self.env.company` of pos_config table,
this error is generated when it's try to create the
record for pos config from pos_resturant module
by data file (defined on this commit)

odoo@3236c1c

as picking_type_id field in pos_config is required
and we set default value by fetching warehouse for related company
but here as company is archived, related warehouse is also
archived and that why we didnot get picking_type_id
for archived company and that will raise Error :

```
  File "/home/odoo/src/odoo/17.0/odoo/models.py", line 4787, in _create
    cr.execute(SQL(
  File "/home/odoo/src/odoo/17.0/odoo/sql_db.py", line 332, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.NotNullViolation: null value in column "picking_type_id" of relation "pos_config" violates not-null constraint
```

closes odoo#151719

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
  • Loading branch information
atp-odoo committed Apr 19, 2024
1 parent 5ed5568 commit 34b9bf8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/point_of_sale/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _default_warehouse_id(self):
return self.env['stock.warehouse'].search(self.env['stock.warehouse']._check_company_domain(self.env.company), limit=1).id

def _default_picking_type_id(self):
return self.env['stock.warehouse'].search(self.env['stock.warehouse']._check_company_domain(self.env.company), limit=1).pos_type_id.id
return self.env['stock.warehouse'].with_context(active_test=False).search(self.env['stock.warehouse']._check_company_domain(self.env.company), limit=1).pos_type_id.id

def _default_sale_journal(self):
return self.env['account.journal'].search([
Expand Down

0 comments on commit 34b9bf8

Please sign in to comment.