@@ -1353,4 +1353,145 @@ def _add_billing_lines_to_invoice(self, invoice, billing_lines):
13531353 default_product .categ_id .property_account_income_categ_id .id ,
13541354 }
13551355
1356- self .env ['account.move.line' ].create (invoice_line_vals )
1356+ self .env ['account.move.line' ].create (invoice_line_vals )
1357+
1358+
1359+ class RecordsBillingLine (models .Model ):
1360+ _name = 'records.billing.line'
1361+ _description = 'Billing Line Item'
1362+ _rec_name = 'description'
1363+
1364+ billing_period_id = fields .Many2one (
1365+ 'records.billing.period' , string = 'Billing Period' ,
1366+ required = True , ondelete = 'cascade' )
1367+ customer_id = fields .Many2one (
1368+ 'res.partner' , string = 'Customer' , required = True )
1369+ department_id = fields .Many2one (
1370+ 'records.department' , string = 'Department' )
1371+ service_request_id = fields .Many2one (
1372+ 'records.service.request' , string = 'Service Request' )
1373+
1374+ line_type = fields .Selection ([
1375+ ('storage' , 'Storage Fee' ),
1376+ ('service' , 'Service Fee' ),
1377+ ('product' , 'Product Sale' ),
1378+ ('adjustment' , 'Adjustment' )
1379+ ], string = 'Line Type' , required = True )
1380+
1381+ description = fields .Text (string = 'Description' , required = True )
1382+ quantity = fields .Float (string = 'Quantity' , default = 1.0 , digits = (12 , 2 ))
1383+ unit_price = fields .Float (string = 'Unit Price' , digits = (12 , 4 ))
1384+ amount = fields .Float (
1385+ string = 'Amount' , compute = '_compute_amount' , store = True ,
1386+ digits = (12 , 2 ))
1387+
1388+ # Additional Information
1389+ notes = fields .Text (string = 'Notes' )
1390+
1391+ @api .depends ('quantity' , 'unit_price' )
1392+ def _compute_amount (self ):
1393+ for line in self :
1394+ line .amount = line .quantity * line .unit_price
1395+
1396+
1397+ class RecordsServicePricing (models .Model ):
1398+ _name = 'records.service.pricing'
1399+ _description = 'Comprehensive Service Pricing Configuration'
1400+ _rec_name = 'name'
1401+
1402+ name = fields .Char (string = 'Service Name' , required = True )
1403+ service_code = fields .Char (string = 'Service Code' , required = True )
1404+ action_code = fields .Char (string = 'Action Code' , help = "STORE, SELL, ADD, etc." )
1405+ object_code = fields .Char (string = 'Object Code' , help = "01, BX, CONTAINER, etc." )
1406+
1407+ service_category = fields .Selection ([
1408+ ('storage' , 'Storage Services' ),
1409+ ('product' , 'Product Sales' ),
1410+ ('box_management' , 'Box Management' ),
1411+ ('transportation' , 'Transportation & Delivery' ),
1412+ ('destruction' , 'Destruction Services' ),
1413+ ('retrieval' , 'Retrieval Services' ),
1414+ ('shred_bin' , 'Shred Bin Services' ),
1415+ ('special' , 'Special Services' )
1416+ ], string = 'Service Category' , required = True )
1417+
1418+ # Pricing
1419+ base_price = fields .Float (string = 'Base Price' , digits = (12 , 2 ))
1420+ per_unit_price = fields .Float (
1421+ string = 'Per Unit Price' , digits = (12 , 4 ),
1422+ help = "Additional cost per unit/box/mile etc." )
1423+ minimum_charge = fields .Float (
1424+ string = 'Minimum Charge' , digits = (12 , 2 ))
1425+
1426+ # Billing Type
1427+ billing_type = fields .Selection ([
1428+ ('invoice' , 'Direct Invoice' ),
1429+ ('workorder' , 'Workorder Required' ),
1430+ ('recurring' , 'Recurring Monthly' )
1431+ ], string = 'Billing Type' , default = 'invoice' )
1432+
1433+ requires_approval = fields .Boolean (string = 'Requires Approval' , default = False )
1434+ accumulate = fields .Boolean (string = 'Accumulate Charges' , default = False )
1435+
1436+ # Quantity Breaks
1437+ quantity_breaks = fields .One2many (
1438+ 'records.service.pricing.break' , 'pricing_id' ,
1439+ string = 'Quantity Breaks' )
1440+
1441+ active = fields .Boolean (string = 'Active' , default = True )
1442+ company_id = fields .Many2one (
1443+ 'res.company' , string = 'Company' ,
1444+ default = lambda self : self .env .company )
1445+
1446+
1447+ class RecordsServicePricingBreak (models .Model ):
1448+ _name = 'records.service.pricing.break'
1449+ _description = 'Service Pricing Quantity Breaks'
1450+ _rec_name = 'min_quantity'
1451+
1452+ pricing_id = fields .Many2one (
1453+ 'records.service.pricing' , string = 'Pricing' ,
1454+ required = True , ondelete = 'cascade' )
1455+ min_quantity = fields .Float (string = 'Minimum Quantity' , required = True )
1456+ max_quantity = fields .Float (string = 'Maximum Quantity' )
1457+ unit_price = fields .Float (string = 'Unit Price' , digits = (12 , 4 ))
1458+ discount_percent = fields .Float (string = 'Discount %' , digits = (5 , 2 ))
1459+
1460+
1461+ # Add billing period reference to account.move (invoices)
1462+ class AccountMove (models .Model ):
1463+ _inherit = 'account.move'
1464+
1465+ billing_period_id = fields .Many2one (
1466+ 'records.billing.period' , string = 'Billing Period' ,
1467+ help = "The billing period this invoice was generated from" )
1468+
1469+
1470+ # Enhanced the existing RecordsServiceRequest model
1471+ class RecordsServiceRequestEnhanced (models .Model ):
1472+ _inherit = 'records.service.request'
1473+
1474+ # Enhanced pricing fields
1475+ actual_cost = fields .Float (
1476+ string = 'Actual Cost' , digits = (12 , 2 ),
1477+ help = "Final billed amount for this service" )
1478+ cost_breakdown = fields .Text (
1479+ string = 'Cost Breakdown' ,
1480+ help = "Detailed breakdown of how the cost was calculated" )
1481+
1482+ # Billing integration
1483+ billing_period_id = fields .Many2one (
1484+ 'records.billing.period' , string = 'Billing Period' )
1485+ billing_line_id = fields .Many2one (
1486+ 'records.billing.line' , string = 'Billing Line' )
1487+ invoiced = fields .Boolean (string = 'Invoiced' , default = False )
1488+ completion_date = fields .Datetime (string = 'Completion Date' )
1489+
1490+ # Additional service details for pricing
1491+ distance_miles = fields .Float (
1492+ string = 'Distance (Miles)' , digits = (8 , 2 ),
1493+ help = "Distance for transportation cost calculation" )
1494+ boxes_count = fields .Integer (
1495+ string = 'Number of Boxes' , default = 1 )
1496+ hard_drives_count = fields .Integer (
1497+ string = 'Number of Hard Drives' , default = 0 )
0 commit comments