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
- Add a Review Status Field:
- Introduce a new status (To Review, Approved) to invoices to indicate whether the e-invoice can be posted.
- Modify Validation Workflow:
- Prevent automatic e-invoice posting upon invoice validation.
- Ensure e-invoice posting occurs only when explicitly triggered by an approved user.
- Approval Workflow:
- Use Odoo’s Approval module or a custom workflow to handle the approval process.
- 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:
- Go to Settings > Approvals and create a new approval request type for e-invoice posting.
- Add a related field on invoices to link approval requests.
- 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
- Invoice Creation and Validation:
- Invoice is created and validated as usual.
- E-invoice is not posted automatically.
- Review and Approval:
- Finance or management team reviews the invoice.
- Approval changes the status to Approved.
- 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.