mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-24 11:02:02 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo import fields, models, _
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
|
|
@ -14,14 +13,14 @@ class AccountMove(models.Model):
|
|||
|
||||
val_list = []
|
||||
log_list = []
|
||||
not_posted_before = self.filtered(lambda r: not r.posted_before)
|
||||
posted = super()._post(soft) # We need the move name to be set, but we also need to know which move are posted for the first time.
|
||||
for line in (not_posted_before & posted).line_ids.filtered(lambda ml: ml.vehicle_id and ml.move_id.move_type == 'in_invoice'):
|
||||
for line in posted.line_ids:
|
||||
if not line.vehicle_id or line.vehicle_log_service_ids\
|
||||
or line.move_id.move_type != 'in_invoice'\
|
||||
or line.display_type != 'product':
|
||||
continue
|
||||
val = line._prepare_fleet_log_service()
|
||||
log = _(
|
||||
'Service Vendor Bill: %s',
|
||||
line.move_id._get_html_link(),
|
||||
)
|
||||
log = _('Service Vendor Bill: %s', line.move_id._get_html_link())
|
||||
val_list.append(val)
|
||||
log_list.append(log)
|
||||
log_service_ids = self.env['fleet.vehicle.log.services'].create(val_list)
|
||||
|
|
@ -36,6 +35,8 @@ class AccountMoveLine(models.Model):
|
|||
vehicle_id = fields.Many2one('fleet.vehicle', string='Vehicle', index='btree_not_null')
|
||||
# used to decide whether the vehicle_id field is editable
|
||||
need_vehicle = fields.Boolean(compute='_compute_need_vehicle')
|
||||
vehicle_log_service_ids = fields.One2many(export_string_translation=False,
|
||||
comodel_name='fleet.vehicle.log.services', inverse_name='account_move_line_id') # One2one
|
||||
|
||||
def _compute_need_vehicle(self):
|
||||
self.need_vehicle = False
|
||||
|
|
@ -45,7 +46,16 @@ class AccountMoveLine(models.Model):
|
|||
return {
|
||||
'service_type_id': vendor_bill_service.id,
|
||||
'vehicle_id': self.vehicle_id.id,
|
||||
'amount': self.debit,
|
||||
'vendor_id': self.partner_id.id,
|
||||
'description': self.name,
|
||||
'account_move_line_id': self.id,
|
||||
}
|
||||
|
||||
def write(self, vals):
|
||||
if 'vehicle_id' in vals and not vals['vehicle_id']:
|
||||
self.sudo().vehicle_log_service_ids.with_context(ignore_linked_bill_constraint=True).unlink()
|
||||
return super().write(vals)
|
||||
|
||||
def unlink(self):
|
||||
self.sudo().vehicle_log_service_ids.with_context(ignore_linked_bill_constraint=True).unlink()
|
||||
return super().unlink()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue