Deep dive: Account, Stock, Sale, Purchase — +800 LOC business logic

Account:
- Multi-currency: company_currency_id, amount_total_signed
- Lock dates on res.company (period, fiscal year, tax) + enforcement in action_post
- Recurring entries: account.move.recurring with action_generate (copy+advance)
- Tax groups: amount_type='group' computes child taxes with include_base_amount
- ComputeTaxes batch function, findTaxAccount helper

Stock:
- Lot/Serial tracking: enhanced stock.lot with expiration dates + qty compute
- Routes: stock.route model with product/category/warehouse selectable flags
- Rules: stock.rule model with pull/push/buy/manufacture actions + procure methods
- Returns: action_return on picking (swap locations, copy moves)
- Product tracking extension (none/lot/serial) + route_ids M2M

Sale:
- Pricelist: get_product_price with fixed/percentage/formula computation
- Margin: purchase_price, margin, margin_percent on line + order totals
- Down payments: action_create_down_payment (deposit invoice at X%)

Purchase:
- 3-way matching: action_create_bill now updates qty_invoiced on PO lines
- Purchase agreements: purchase.requisition + line with state machine

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc
2026-04-03 19:05:39 +02:00
parent d9171191af
commit b8fa4719ad
14 changed files with 802 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
package models
import "odoo-go/pkg/orm"
// initAccountCompanyExtension extends res.company with accounting lock date fields.
// Mirrors: odoo/addons/account/models/company.py ResCompany (extends res.company)
//
// In Python Odoo:
//
// class ResCompany(models.Model):
// _inherit = 'res.company'
// period_lock_date = fields.Date(...)
// fiscalyear_lock_date = fields.Date(...)
// tax_lock_date = fields.Date(...)
//
// Lock dates prevent posting journal entries before a certain date:
// - period_lock_date: blocks non-adviser users
// - fiscalyear_lock_date: blocks all users
// - tax_lock_date: blocks tax-related entries
func initAccountCompanyExtension() {
c := orm.ExtendModel("res.company")
c.AddFields(
orm.Date("period_lock_date", orm.FieldOpts{String: "Lock Date for Non-Advisers"}),
orm.Date("fiscalyear_lock_date", orm.FieldOpts{String: "Lock Date for All Users"}),
orm.Date("tax_lock_date", orm.FieldOpts{String: "Tax Lock Date"}),
)
}