On Document App do we have any module/feature which shows number of users viewed the document?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hii,
i dont know which odoo version version you will use here is custom module
models/document_view_log.py
from odoo import models, fields class DocumentViewLog(models.Model): _name = 'documents.document.view.log' _description = 'Document View Log' _order = 'viewed_at desc' user_id = fields.Many2one('res.users', string="User", required=True) document_id = fields.Many2one('documents.document', string="Document", required=True, ondelete="cascade") viewed_at = fields.Datetime(string="Viewed At", default=fields.Datetime.now)
models/documents_document.py
pythorom odoo import models, api, fields class DocumentsDocument(models.Model): _inherit = 'documents.document' view_log_count = fields.Integer(string="Views", compute='_compute_view_log_count') def _compute_view_log_count(self): for doc in self: doc.view_log_count = self.env['documents.document.view.log'].search_count([ ('document_id', '=', doc.id) ]) def action_view_logs(self): return { 'name': 'View Logs', 'type': 'ir.actions.act_window', 'res_model': 'documents.document.view.log', 'view_mode': 'tree,form', 'domain': [('document_id', '=', self.id)], 'context': {'default_document_id': self.id}, } def read(self, fields=None, load='_classic_read'): res = super().read(fields, load) for doc in self: self.env['documents.document.view.log'].create({ 'user_id': self.env.uid, 'document_id': doc.id, }) return res
views/document_view_log_views.xml
<odoo> <record id="view_document_view_log_tree" model="ir.ui.view"> <field name="name">documents.document.view.log.tree</field> <field name="model">documents.document.view.log</field> <field name="arch" type="xml"> <tree string="Document Views"> <field name="user_id"/> <field name="document_id"/> <field name="viewed_at"/> </tree> </field> </record> </odoo>
views/documents_document_views.xml
<odoo> <record id="view_documents_document_form_inherit" model="ir.ui.view"> <field name="name">documents.document.form.inherit.viewlog</field> <field name="model">documents.document</field> <field name="inherit_id" ref="documents.view_documents_document_form"/> <field name="arch" type="xml"> <xpath expr="//form/header" position="inside"> <button name="action_view_logs" type="object" class="oe_stat_button" icon="fa-eye"> <field name="view_log_count" widget="statinfo" string="Views"/> </button> </xpath> </field> </record> </odoo>
manifest file and other files make as your requirements
i hope this module is help full
it is module is version 16
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký