This code extends Odoo’s `account.move` model to introduce a custom feature that allows users to **combine multiple draft vendor bills** into a single consolidated bill. The main purpose is to simplify vendor billing management by merging multiple invoices from the same vendor into one document.
The method `action_combine_bills` is designed to be triggered from the user interface, typically through a button action. It first filters the selected records to include only **draft vendor bills** (`move_type == 'in_invoice'` and `state == 'draft'`). If no valid bills are selected, the system raises a `UserError` prompting the user to select at least one draft bill. Next, it ensures that all selected bills belong to the **same vendor** by comparing their `partner_id` values. If bills from different vendors are selected, another `UserError` is raised to prevent combining them.
Once the validation checks pass, the method collects all invoice line items from the selected bills, including details such as product, description, quantity, price, taxes, and account. It then creates a new vendor bill record with today’s date, assigning the same vendor and all combined invoice lines. The result is a single, comprehensive bill that consolidates all line items from the original bills. Finally, the method returns an Odoo action dictionary that automatically opens the newly created bill in **form view**, allowing the user to review, validate, or modify it before posting.
This implementation improves efficiency and reduces redundancy when managing multiple draft bills from the same vendor, making it easier for accounting users to handle bulk invoices in Odoo.