Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
769 Vistas

Environment:

- Odoo Version: 16.0 (Enterprise)

- Module: Accounting


Business Requirement:

We need to stop Einvoice posting automatically once Invoice gets validated in Odoo16EE. Einvoice Posting should be done only after Reviewing the invoiced data by management


Use Case:

We have configured EInvoice using IAP in Default Odoo16EE its connected with Live environment. Once invoice is created and validated, system automatically posting einvoice also in GST Portal. This automatic e-invoice posting to gst portal should be stopped even after Invoice validation. Once its gets verified and approved by Finance team, it needs to be posted through Odoo


Questions:

1. Is there any existing functionality in Odoo 16 to control this?

2. If not, what would be the recommended approach to implement this?



Any guidance on implementing this feature would be greatly appreciated. Technical implementation details or pointers to similar solutions would be helpful.

Avatar
Descartar
Autor Mejor respuesta

Thank you very much for your detailed info. will workout the same.

Regards,

Odoo@Tenthplanet


Avatar
Descartar
Mejor respuesta

To meet your requirement of controlling e-invoice posting in Odoo 16 Enterprise Edition, where e-invoice posting to the GST portal only happens after a review and approval process, here are detailed answers and steps:

1. Existing Functionality in Odoo 16

There is no direct built-in feature in Odoo 16 to control the posting of e-invoices to the GST portal after invoice validation. Odoo’s default behavior posts e-invoices automatically upon validation when configured with IAP.

You will need to customize the workflow to include an intermediate approval process before the e-invoice is posted.

2. Recommended Approach to Implement This Feature

Overview of Implementation

  1. Add a Review Status Field:
    • Introduce a new status (To Review, Approved) to invoices to indicate whether the e-invoice can be posted.
  2. Modify Validation Workflow:
    • Prevent automatic e-invoice posting upon invoice validation.
    • Ensure e-invoice posting occurs only when explicitly triggered by an approved user.
  3. Approval Workflow:
    • Use Odoo’s Approval module or a custom workflow to handle the approval process.
  4. Restrict Posting to Authorized Users:
    • Add access rights or buttons visible only to specific roles (e.g., Finance Team).

3. Step-by-Step Technical Implementation

Step 1: Add a Review Status Field

Add a new field to the invoice (account.move) to track its approval status.

pythonCopy codefrom odoo import models, fields

class AccountMove(models.Model):
    _inherit = 'account.move'

    review_status = fields.Selection([
        ('to_review', 'To Review'),
        ('approved', 'Approved'),
    ], string="Review Status", default='to_review')

Step 2: Modify Automatic Posting Logic

Override the e-invoice posting logic to stop it from triggering upon validation.

pythonCopy codefrom odoo import models

class AccountMove(models.Model):
    _inherit = 'account.move'

    def _post_einvoice(self):
        # Prevent auto-posting if not approved
        for invoice in self:
            if invoice.review_status != 'approved':
                return False  # Skip posting e-invoice
        return super(AccountMove, self)._post_einvoice()  # Continue normal posting for approved invoices

Step 3: Add a Button for Manual Posting

Add a button to manually trigger e-invoice posting once the invoice is approved.

pythonCopy codefrom odoo import models

class AccountMove(models.Model):
    _inherit = 'account.move'

    def action_post_einvoice(self):
        self.ensure_one()
        if self.review_status != 'approved':
            raise ValidationError("Invoice must be approved before posting the e-invoice.")
        self._post_einvoice()

In your XML view:

xmlCopy code<record id="view_invoice_form" model="ir.ui.view">
    <field name="model">account.move</field>
    <field name="inherit_id" ref="account.view_move_form" />
    <field name="arch" type="xml">
        <xpath expr="//header" position="inside">
            <button name="action_post_einvoice" type="object" string="Post E-Invoice"
                    attrs="{'invisible': [('review_status', '!=', 'approved')]}" class="btn-primary" />
        </xpath>
    </field>
</record>

Step 4: Configure an Approval Workflow

Use the Approvals module to configure a review process:

  1. Go to Settings > Approvals and create a new approval request type for e-invoice posting.
  2. Add a related field on invoices to link approval requests.
  3. Update the review_status field when an approval is granted.

Alternatively, create a custom approval workflow:

pythonCopy codedef action_approve(self):
    for record in self:
        record.review_status = 'approved'

Step 5: Adjust Access Rights

Restrict e-invoice posting to specific roles (e.g., Finance Manager).

  • Create a security group in ir.model.access.csv:
csvCopy codeid,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_move_finance_manager,access_account_move_finance_manager,model_account_move,group_account_invoice_manager,1,1,1,1
  • Assign this group to the manual posting button.

4. Full Workflow

  1. Invoice Creation and Validation:
    • Invoice is created and validated as usual.
    • E-invoice is not posted automatically.
  2. Review and Approval:
    • Finance or management team reviews the invoice.
    • Approval changes the status to Approved.
  3. Manual E-Invoice Posting:
    • A user with sufficient access posts the e-invoice through a manual action.

5. Benefits

  • Prevents accidental posting of incorrect e-invoices.
  • Introduces a clear review and approval workflow.
  • Allows flexibility in managing roles and responsibilities.

6. Additional Considerations

  • Notifications: Notify responsible users when invoices are ready for review.
  • Audit Trail: Record who approved and posted the e-invoice for compliance.
  • Testing: Thoroughly test the workflow in a staging environment.

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
abr 25
848
1
jul 24
907
0
jun 24
746
1
nov 21
3303
1
dic 24
1053