[FIX] exp_transaction_documents: seen and unseen transactions
This commit is contained in:
parent
09281b50a0
commit
2504f83eb9
|
|
@ -70,7 +70,7 @@ class Transaction(models.Model):
|
|||
compute='compute_receive_manger_id')
|
||||
current_is_receive_manger = fields.Boolean(string='Is Manager', compute="set_to_is_manager")
|
||||
to_user_have_leave = fields.Boolean(string="Have Leave?", default=False, compute='compute_have_leave')
|
||||
is_reade = fields.Boolean(string="Is Reade?!", default=True)
|
||||
is_reade = fields.Boolean(string="Is Reade?!")
|
||||
is_favorite = fields.Selection([
|
||||
('0', 'not'),
|
||||
('1', 'Favorite'),
|
||||
|
|
@ -78,6 +78,9 @@ class Transaction(models.Model):
|
|||
signature = fields.Binary("Signature image",compute='compute_img',store=True)
|
||||
tran_tag = fields.Many2many(comodel_name='transaction.tag', string='Tags')
|
||||
add_rank = fields.Integer(string='Transaction Rank')
|
||||
seen_user_ids = fields.Many2many('res.users')
|
||||
seen_before = fields.Boolean(compute="_compute_seen_before")
|
||||
|
||||
|
||||
@api.depends('type','subject')
|
||||
def compute_img(self):
|
||||
|
|
@ -89,10 +92,16 @@ class Transaction(models.Model):
|
|||
def action_read(self):
|
||||
for rec in self:
|
||||
rec.is_reade = True
|
||||
user_id = rec.env.user.id
|
||||
if user_id not in rec.seen_user_ids.ids:
|
||||
rec.seen_user_ids = [(4, user_id)]
|
||||
|
||||
def action_unread(self):
|
||||
for rec in self:
|
||||
rec.is_reade = False
|
||||
user_id = rec.env.user.id
|
||||
if user_id in rec.seen_user_ids.ids:
|
||||
rec.seen_user_ids = [(3, user_id)]
|
||||
|
||||
def add_to_favorite(self):
|
||||
for rec in self:
|
||||
|
|
@ -237,25 +246,40 @@ class Transaction(models.Model):
|
|||
record.state = 'to_approve'
|
||||
else:
|
||||
record.action_send()
|
||||
user_id = record.env.user.id
|
||||
if user_id not in record.seen_user_ids.ids:
|
||||
record.seen_user_ids = [(6, 0, [user_id])]
|
||||
|
||||
def action_send(self):
|
||||
for record in self:
|
||||
record.state = 'send'
|
||||
record.send_date = datetime.today()
|
||||
record.is_reade = False
|
||||
user_id = record.env.user.id
|
||||
if user_id not in record.seen_user_ids.ids:
|
||||
record.seen_user_ids = [(6, 0, [user_id])]
|
||||
|
||||
def action_approve(self):
|
||||
for record in self:
|
||||
record.state = 'send'
|
||||
record.is_reade = False
|
||||
user_id = record.env.user.id
|
||||
if user_id not in record.seen_user_ids.ids:
|
||||
record.seen_user_ids = [(6, 0, [user_id])]
|
||||
|
||||
def action_cancel(self):
|
||||
for record in self:
|
||||
record.state = 'canceled'
|
||||
user_id = record.env.user.id
|
||||
if user_id not in record.seen_user_ids.ids:
|
||||
record.seen_user_ids = [(6, 0, [user_id])]
|
||||
|
||||
def action_reopen(self):
|
||||
for record in self:
|
||||
record.state = 'send'
|
||||
user_id = record.env.user.id
|
||||
if user_id not in record.seen_user_ids.ids:
|
||||
record.seen_user_ids = [(6, 0, [user_id])]
|
||||
params = record.env.context.get('params', {})
|
||||
model = params.get('model', False)
|
||||
if model == 'incoming.transaction':
|
||||
|
|
@ -280,6 +304,9 @@ class Transaction(models.Model):
|
|||
def set_to_draft(self):
|
||||
for record in self:
|
||||
record.state = 'draft'
|
||||
user_id = record.env.user.id
|
||||
if user_id not in record.seen_user_ids.ids:
|
||||
record.seen_user_ids = [(6, 0, [user_id])]
|
||||
|
||||
def trace_create_ids(self, name, transaction, action):
|
||||
''' method to create log trace in transaction'''
|
||||
|
|
@ -434,3 +461,11 @@ class Transaction(models.Model):
|
|||
# partner_ids=partner_ids,
|
||||
# subtype_xmlid="mail.mt_comment")
|
||||
return True
|
||||
|
||||
def _compute_seen_before(self):
|
||||
for rec in self:
|
||||
rec.seen_before = rec.env.user.id in rec.seen_user_ids.ids
|
||||
|
||||
def create(self, vals):
|
||||
vals['seen_user_ids'] = [(4, self.env.user.id)]
|
||||
return super(Transaction, self).create(vals)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<field name="name">common.incoming.transaction.tree</field>
|
||||
<field name="model">incoming.transaction</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="transaction_date desc" decoration-info="is_reade == False"
|
||||
<tree default_order="transaction_date desc" decoration-info="seen_before == False"
|
||||
string="Incoming Transaction" create="false" edit="false">
|
||||
<field name="from_id"/>
|
||||
<field name="partner_id"/>
|
||||
|
|
@ -60,6 +60,7 @@
|
|||
<field name="attachment_count"/>
|
||||
<field name="is_favorite" string=" " widget="priority"/>
|
||||
<field name="is_reade" invisible="1"/>
|
||||
<field name="seen_before" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
<field name="model">internal.transaction</field>
|
||||
<field name="priority" eval="1"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="transaction_date desc" decoration-info="is_reade == False"
|
||||
<tree default_order="transaction_date desc" decoration-info="seen_before == False"
|
||||
string="Internal Transaction" create="false" edit="false">
|
||||
<field name="name"/>
|
||||
<field name="transaction_date"/>
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
<field name="state" optional="show"/>
|
||||
<field name="is_favorite" string=" " widget="priority"/>
|
||||
<field name="is_reade" invisible="1"/>
|
||||
<field name="seen_before" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
<field name="model">outgoing.transaction</field>
|
||||
<field name="priority" eval="1"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="transaction_date desc" decoration-info="is_reade == False"
|
||||
<tree default_order="transaction_date desc" decoration-info="seen_before == False"
|
||||
string="Outgoing External Transaction" create="false" edit="false">
|
||||
<field name="name"/>
|
||||
<field name="transaction_date"/>
|
||||
|
|
@ -57,6 +57,7 @@
|
|||
<field name="cc_ids" widget="many2many_tags" optional="hide"/>
|
||||
<field name="is_favorite" string=" " widget="priority" optional="hide"/>
|
||||
<field name="is_reade" invisible="1"/>
|
||||
<field name="seen_before" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ class ArchiveTransactionWizard(models.TransientModel):
|
|||
transaction = self.outgoing_transaction_id
|
||||
name = 'outgoing_transaction_id'
|
||||
transaction.state = 'closed'
|
||||
user_id = transaction.env.user.id
|
||||
if user_id not in transaction.seen_user_ids.ids:
|
||||
transaction.seen_user_ids = [(6, 0, [user_id])]
|
||||
transaction.archive_user_id = from_id.id
|
||||
transaction.trace_ids.create({
|
||||
'from_id': from_id.id,
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ class ForwardTransactionWizard(models.TransientModel):
|
|||
elif partner.type == 'employee':
|
||||
partner_ids.append(partner.user_id.partner_id.id)
|
||||
transaction.state = 'send'
|
||||
user_id = transaction.env.user.id
|
||||
if user_id not in transaction.seen_user_ids.ids:
|
||||
transaction.seen_user_ids = [(6, 0, [user_id])]
|
||||
transaction.action_send_notification(subj, msg, partner_ids)
|
||||
if self.incoming_transaction_id:
|
||||
if transaction.state == 'draft':
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ class RejectReasonWizard(models.TransientModel):
|
|||
employee = transaction.current_employee()
|
||||
transaction.reason = self.reason
|
||||
transaction.state = 'canceled'
|
||||
user_id = transaction.env.user.id
|
||||
if user_id not in transaction.seen_user_ids.ids:
|
||||
transaction.seen_user_ids = [(6, 0, [user_id])]
|
||||
transaction.trace_ids.create({
|
||||
'action': 'refuse',
|
||||
'to_id': transaction.employee_id.id,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ class TransactionReturnWizard(models.TransientModel):
|
|||
transaction.forward_user_id = transaction.employee_id.user_id.id
|
||||
|
||||
transaction.state = 'reply'
|
||||
user_id = transaction.env.user.id
|
||||
if user_id not in transaction.seen_user_ids.ids:
|
||||
transaction.seen_user_ids = [(6, 0, [user_id])]
|
||||
forward_entity = self.env['cm.entity'].search([('user_id', '=', transaction.forward_user_id.id)], limit=1)
|
||||
|
||||
# Check if attachment_id and filename are not empty before creating attachment
|
||||
|
|
|
|||
Loading…
Reference in New Issue