Update account_move
This commit is contained in:
parent
3846885710
commit
d93628ae6e
|
|
@ -1,11 +1,45 @@
|
||||||
from odoo import api, fields, models, _
|
# -*- coding: utf-8 -*-
|
||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
class AccountMove(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = "account.move"
|
|
||||||
|
_inherit = 'account.move'
|
||||||
|
|
||||||
attach_no = fields.Integer(compute='get_attachments')
|
attach_no = fields.Integer(compute='get_attachments')
|
||||||
res_model = fields.Char()
|
|
||||||
res_id = fields.Integer()
|
res_id = fields.Integer()
|
||||||
|
res_model = fields.Char()
|
||||||
|
|
||||||
|
def get_attachments(self):
|
||||||
|
self.ensure_one()
|
||||||
|
|
||||||
|
action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
|
||||||
|
action['domain'] = [
|
||||||
|
('res_model', '=', 'account.move'),
|
||||||
|
('res_id', 'in',self.ids), ]
|
||||||
|
domain = [
|
||||||
|
('res_model', '=', 'account.move'),
|
||||||
|
('res_id', 'in', self.ids), ]
|
||||||
|
related_ids = self.ids
|
||||||
|
related_models = 'account.move'
|
||||||
|
|
||||||
|
if self.res_id and self.res_model:
|
||||||
|
related_ids = self.ids + [self.res_id]
|
||||||
|
related_models = ['account.move', self.res_model]
|
||||||
|
action['domain'] = [
|
||||||
|
('res_model', 'in', related_models),
|
||||||
|
('res_id', 'in', related_ids), ]
|
||||||
|
domain = [
|
||||||
|
('res_model', 'in', related_models),
|
||||||
|
('res_id', 'in', related_ids), ]
|
||||||
|
|
||||||
|
# Context for creating new attachments
|
||||||
|
action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id)
|
||||||
|
# Update attachment count for smart button
|
||||||
|
|
||||||
|
|
||||||
|
self.attach_no = self.env['ir.attachment'].search_count(domain)
|
||||||
|
|
||||||
|
return action
|
||||||
|
|
||||||
# def get_attachments(self):
|
# def get_attachments(self):
|
||||||
# action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
|
# action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
|
||||||
|
|
@ -14,30 +48,3 @@ class AccountMove(models.Model):
|
||||||
# domain = [('res_model', '=', 'account.move'), ('res_id', '=', self.id)]
|
# domain = [('res_model', '=', 'account.move'), ('res_id', '=', self.id)]
|
||||||
# self.attach_no = self.env['ir.attachment'].search_count(domain)
|
# self.attach_no = self.env['ir.attachment'].search_count(domain)
|
||||||
# return action
|
# return action
|
||||||
|
|
||||||
def get_attachments(self):
|
|
||||||
self.ensure_one()
|
|
||||||
|
|
||||||
action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
|
|
||||||
related_ids = self.ids
|
|
||||||
related_models = 'account.move'
|
|
||||||
|
|
||||||
if self.res_id and self.res_model:
|
|
||||||
related_ids = self.ids + [res_id]
|
|
||||||
related_models = ['account.move', self.res_model]
|
|
||||||
|
|
||||||
action['domain'] = [
|
|
||||||
('res_model', 'in',related_models),
|
|
||||||
('res_id', 'in', related_ids),]
|
|
||||||
|
|
||||||
# Context for creating new attachments
|
|
||||||
action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id)
|
|
||||||
# Update attachment count for smart button
|
|
||||||
domain = [
|
|
||||||
('res_model', 'in', related_models),
|
|
||||||
('res_id', 'in', related_ids),]
|
|
||||||
|
|
||||||
self.attach_no = self.env['ir.attachment'].search_count(domain)
|
|
||||||
|
|
||||||
return action
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue