diff --git a/project_wip_material/models/stock_move.py b/project_wip_material/models/stock_move.py index 078f9ab9..cdf6dcb0 100644 --- a/project_wip_material/models/stock_move.py +++ b/project_wip_material/models/stock_move.py @@ -63,20 +63,22 @@ def _generate_consumption_account_move(self, qty, description, svl_id, cost): qty=qty, description=description, svl_id=svl_id, - cost=cost) + cost=cost + ) def _generate_consumption_return_account_move(self, qty, description, svl_id, cost): self._check_project_has_wip_account() wip_account = self._get_wip_account() journal_id, dummy, dummy, acc_valuation = self._get_accounting_data_for_valuation() self.with_company(self.project_id.company_id.id)._create_account_move_line( - credit_account_id=acc_valuation, - debit_account_id=wip_account.id, + credit_account_id=wip_account.id, + debit_account_id=acc_valuation, journal_id=journal_id, qty=qty, description=description, svl_id=svl_id, - cost=cost) + cost=cost, + ) def _check_project_has_wip_account(self): project = self.project_id @@ -104,4 +106,5 @@ def _get_wip_account(self): return self.project_id.type_id.wip_account_id def _get_project_analytic_account(self): + self = self.with_company(self.company_id.id) return self.project_id.analytic_account_id diff --git a/project_wip_timesheet/models/account_analytic_line.py b/project_wip_timesheet/models/account_analytic_line.py index feaf3363..596e90f4 100644 --- a/project_wip_timesheet/models/account_analytic_line.py +++ b/project_wip_timesheet/models/account_analytic_line.py @@ -91,6 +91,8 @@ def _update_salary_account_move(self): move_name=self.salary_account_move_id.name, ) ) + + self.salary_account_move_id.state = "draft" vals = self._get_salary_account_move_vals() self.salary_account_move_id.write(vals) self.salary_account_move_id.post() @@ -109,7 +111,7 @@ def _reverse_salary_account_move_for_updated_timesheet(self): move_name=self.salary_account_move_id.name, ) ) - self.salary_account_move_id.reverse_moves() + self.salary_account_move_id._reverse_moves() self.salary_account_move_id = False @@ -126,7 +128,7 @@ def _reverse_salary_account_move_for_deleted_timesheet(self): move_name=self.salary_account_move_id.name, ) ) - self.salary_account_move_id.reverse_moves() + self.salary_account_move_id._reverse_moves() def _is_salary_account_move_reconciled(self): return any(line.reconciled for line in self.salary_account_move_id.line_ids)